news_txt.htmlText = "<p class=\"heading\">Heading goes here!</p><p
class=\"mainBody\">Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat.</p>";
}
};
my_styleSheet.load("styles.css");
For the code contained in styles.css, see the entry for
an example of asynchronously loading style sheets using ActionScript 2.0, see the entry for
TextField.StyleSheet.getStyle()
See also
TextField.StyleSheet.load()
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.
Example
The following example parses the CSS in
whether it parsed successfully, and then writes the parsed CSS in the log file. 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");
}
772
Chapter 7: ActionScript for Flash
.
and loads the style sheet with it. If a style in
cssText
, the properties in
styleSheet
.
styleSheet
css_str
TextField.StyleSheet.getStyle()
) or not (
true
are retained, and only the ones in
. The ActionScript writes information about
. For
).
false
is
cssText
cssText
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?