ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > StyleSheet (TextField.StyleSheet) > parseCSS (StyleSheet.parseCSS method) | |||
public parseCSS(cssText:String) : Boolean
Parses the CSS in cssText and loads the StyleSheet with it. If a style in cssText is already in the StyleSheet, the StyleSheet retains its properties, and only the ones in cssText are added or changed.
To extend the native CSS parsing capability, you can override this method by creating a subclass of the StyleSheet class.
Availability: ActionScript 1.0; Flash Player 7
cssText:String - The CSS text to parse.
Boolean - A Boolean value that indicates whether the text was parsed successfully (true) or not (false).
The following example parses the CSS in css_str. The script displays information about whether it parsed the CSS successfully, and then displays the parsed CSS in the Output panel.
import TextField.StyleSheet;
var css_str:String = ".heading {font-family: Arial, Helvetica, sans-serif; font-size: 24px; font-weight: bold; }";
var my_styleSheet:StyleSheet = new StyleSheet();
if (my_styleSheet.parseCSS(css_str)) {
trace("parsed successfully");
dumpStyles(my_styleSheet);
} else {
trace("unable to parse CSS");
}
//
function dumpStyles(styles: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("");
}
}
|
|
|
|