772
Chapter 7: ActionScript for Flash
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
TextField.StyleSheet.getStyle()
. 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
cssText
The CSS text to parse (a string).
Returns
A Boolean value indicating if the text was parsed successfully (
true
) or not (
false
).
Description
Method; parses the CSS in
cssText
and loads the style sheet with it. If a style in
cssText
is
already in
styleSheet
, the properties in
styleSheet
are retained, and only the ones in
cssText
are added or changed in
styleSheet
.
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
css_str
. The ActionScript writes information about
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");
}
Summary of Contents for FLEX-FLEX ACTIONSCRIPT LANGUAGE
Page 1: ...Flex ActionScript Language Reference...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Page 135: ...case 135 See also break default strict equality switch...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Page 808: ...808 Chapter 7 ActionScript for Flash...
Page 810: ...810 Appendix A Deprecated Flash 4 operators...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Page 822: ...822 Index...