StyleSheet (TextField.StyleSheet)
1151
Parameters
cssText
:String
- The CSS text to parse.
Returns
Boolean
- A Boolean value that indicates whether the text was parsed successfully (
true
) or
not (
false
).
Example
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("");
}
}
setStyle (StyleSheet.setStyle method)
public setStyle(name:String, style:Object) : Void
Adds a new style with the specified name to the StyleSheet object. If the named style does not
already exist in the StyleSheet, it is added. If the named style already exists in the StyleSheet, it
is replaced. If the
style
parameter is
null
, the named style is removed.
Flash Player creates a copy of the style object that you pass to this method.
For a list of supported styles, see the table in the description for the StyleSheet class.
Availability:
ActionScript 1.0; Flash Player 7
Summary of Contents for FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Page 1: ...ActionScript 2 0 Language Reference ...
Page 1352: ...1352 ActionScript classes ...