Formatting text with Cascading Style Sheet styles 429
Combining styles
CSS styles in Flash Player are additive; that is, when styles are nested, each level of nesting can
contribute style information, which is added together to result in the final formatting.
The following example shows some XML data assigned to a text field:
<sectionHeading>This is a section</sectionHeading>
<mainBody>This is some main body text, with one
<emphasized>emphatic</emphasized> word.</mainBody>
For the word emphatic in the above text, the emphasized style is nested within the mainBody
style. The
mainBody style contributes color, font-size, and decoration rules. The emphasized
style adds a font-weight rule to these rules. The word emphatic will be formatted using a
combination of the rules specified by
mainBody and emphasized.
Using style classes
You can create style “classes” (not true ActionScript 2.0 classes) that you can apply to a <p> or
<span> tag using either tag’s class attribute. When applied to a <p> tag, the style affects the
entire paragraph. You can also style a span of text that uses a style class using the
<span> tag.
For example, the following style sheet defines two style classes:
mainBody and emphasis:
.mainBody {
font-family: Arial,Helvetica,sans-serif;
font-size: 24px;
}
.emphasis {
color: #666666;
font-style: italic;
}
Within HTML text you assign to a text field, you can apply these styles to <p> and <span>
tags, as shown in the following snippet:
<p class='mainBody'>This is <span class='emphasis'>really exciting!</
span></p>