EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 433

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Formatting text with Cascading Style Sheet styles 433
} else {
trace("Unable to load CSS file.");
}
};
styles.load(css_url);
8.
Save the file as news_html.fla in the same directory that contains the CSS file you
created in step 3.
9. Select Control > Test Movie to see the styles applied to the HTML text automatically.
Using styles to define new tags
If you define a new style in a style sheet, that style can be used as a tag, in the same way as you
would use a built-in HTML tag. For example, if a style sheet defines a CSS style named
sectionHeading, you can use <sectionHeading> as an element in any text field associated
with the style sheet. This feature lets you assign arbitrary XML-formatted text directly to a
text field, so that the text is automatically formatted using the rules in the style sheet.
For example, the following style sheet creates the new styles
sectionHeading, mainBody,
and
emphasized:
.sectionHeading {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 18px;
display: block
}
.mainBody {
color: #000099;
text-decoration: underline;
font-size: 12px;
display: block
}
.emphasized {
font-weight: bold;
display: inline
}
You could then populate a text field associated with that style sheet with the following XML-
formatted text:
<sectionHeading>This is a section</sectionHeading>
<mainBody>This is some main body text,
with one <emphasized>emphatic</emphasized> word.
</mainBody>
NOTE
In this ActionScript, you are loading the text from an external file. For information on
loading external data, see Chapter 15, “Working with Images, Sound, and Video.”

Table of Contents

Related product manuals