TextField.StyleSheet.parseCSS()
Availability
Flash Player 7.
Usage
styleSheet.parseCSS(cssText:String) : Boolean
Parameters
The CSS text to parse (a string).
cssText
Returns
A Boolean value indicating if the text was parsed successfully (
Description
Method; parses the CSS in
already in
styleSheet
are added or changed in
To extend the native CSS parsing capability, you can override this method by creating a subclass
of the TextField.StyleSheet class. For more information, see "Creating subclasses" in Using
ActionScript in Flash.
Example
The following example parses the CSS in
whether it parsed successfully, and then displays the parsed CSS in the Output panel. Add the
following ActionScript to your AS or FLA file:
var css_str:String = ".heading {font-family: Arial, Helvetica, sans-serif;
font-size: 24px; font-weight: bold; }";
var my_styleSheet:TextField.StyleSheet = new TextField.StyleSheet();
if (my_styleSheet.parseCSS(css_str)) {
trace("parsed successfully");
dumpStyles(my_styleSheet);
} else {
trace("unable to parse CSS");
}
//
function dumpStyles(styles:TextField.StyleSheet):Void {
var styleNames_array:Array = styles.getStyleNames();
for (var i = 0; i<styleNames_array.length; i++) {
var styleName_str:String = styleNames_array[i];
var styleObject:Object = styles.getStyle(styleName_str);
trace(styleName_str);
for (var prop in styleObject) {
trace("\t"+prop+": "+styleObject[prop]);
}
trace("");
}
}
866
Chapter 2: ActionScript Language Reference
and loads the style sheet with it. If a style in
cssText
, the properties in
styleSheet
.
styleSheet
css_str
) or not (
true
are retained, and only the ones in
. The ActionScript displays information about
).
false
is
cssText
cssText
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers