Setstyle (Stylesheet.setstyle Method) - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

Parameters
- The CSS text to parse.
cssText:String
Returns
- A Boolean value that indicates whether the text was parsed successfully (
Boolean
not (
).
false
Example
The following example parses the CSS in
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
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
css_str
parameter is
, the named style is removed.
null
. The script displays information about
StyleSheet (TextField.StyleSheet)
) or
true
1151

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents

Save PDF