Flash 8 Documentation |
|||
| Learning ActionScript 2.0 in Flash > Working with Text and Strings > Formatting text with Cascading Style Sheet styles | |||
Cascading Style Sheet (CSS) styles are a way to work with text styles that can be applied to HTML or XML documents. A style sheet is a collection of formatting rules that specify how to format HTML or XML elements. Each rule associates a style name, or selector, with one or more style properties and their values. For example, the following style defines a selector named bodyText:
.bodyText {
text-align: left
}
You can create styles that redefine built-in HTML formatting tags that Flash Player uses (such as <p> and <li>). You can also create style classes that can be applied to specific HTML elements using the <p> or <span> tag's class attribute, or define new tags.
You use the TextField.StyleSheet class to work with text style sheets. Although the TextField class can be used with Flash Player 6, the TextField.StyleSheet class requires that SWF files target Flash Player 7 or later. You can load styles from an external CSS file or create them natively using ActionScript. To apply a style sheet to a text field that contains HTML- or XML-formatted text, you use the TextField.styleSheet property. The styles defined in the style sheet are mapped automatically to the tags defined in the HTML or XML document.
Using styles sheets involves the following three basic steps:
For more information, see the following topics:
You can find a sample source file, formattedText.fla, in the Samples folder on your hard disk, which shows you how to apply CSS formatting to text that you load into a SWF file at runtime.
In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript\LoadText.
On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/ActionScript/LoadText.
Version 8
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/8/main/00001444.html
Comments
No screen name said on Oct 26, 2006 at 3:44 PM :