MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 435

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

This code creates a new style sheet object named
method. The styles exactly match the ones you created in an external CSS file
setStyle()
earlier in this chapter.
7.
To create the XML text to assign to the text field, open a text editor and enter the following
text into a new document:
<story><title>Flash now has FlashType</title><mainBody><byline>San
Francisco, CA</byline>--Macromedia Inc. announced today a new version
of Flash that features the new FlashType rendering technology. For
more information, visit the <a href="http://
www.macromedia.com">Macromedia Flash website</a></mainBody></story>
If you copy and paste this text string, make sure that you remove any line breaks that
might have been added to the text string. Select Hidden Characters from the pop-up
menu in the Actions panel to see and remove any extra line breaks.
8.
Save the text file as story.xml.
9.
In Flash, add the following code in the Actions panel, following the code in step 6.
This code loads the story.xml document, assigns the style sheet object to the text field's
property, and assigns the XML text to the text field:
styleSheet
var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success:Boolean):Void {
if (success) {
news_txt.styleSheet = styles;
news_txt.text = my_xml;
} else {
trace("Error loading XML.");
}
};
my_xml.load("story.xml");
You are loading XML data from an external file in this ActionScript. For
information on loading external data, see
Sound, and Video."
10.
Save the file as news_xml.fla in the same folder as story.xml.
11.
Run the SWF file (Control > Test Movie) to see the styles automatically applied to the text
in the text field.
that defines styles by using the
styles
Chapter 15, "Working with Images,
Formatting text with Cascading Style Sheet styles
435

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

This manual is also suitable for:

Flash 8

Table of Contents