Using Html-Formatted Text - MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

To create the XML text to assign to the text field, open a text editor and enter the following text
7.
into a new document:
<story><title>Flash Player now supports CSS</title><mainBody><byline>San
Francisco, CA</byline>--Macromedia Inc. announced today a new version of
Flash Player that supports Cascading Style Sheets (CSS) text styles. For
more information, visit the <a href="http://www.macromedia.com">Macromedia
Flash website</a></mainBody></story>
Note: If you copy and paste this text string, make sure that you remove any line breaks that might
have been added to the text file.
Save the text file as myStory.xml.
8.
In Flash, add the following code in the Actions panel, following the code in step 6. This code
9.
loads the myStory.xml document, assigns the style sheet object to the text field's
property, and assigns the XML text to the text field:
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.load("myStory.xml");
myXML.onLoad = function(success) {
if(success){
storyText = myXML;
news_txt.styleSheet = xmlStyles;
news_txt.text = storyText;
}else{
trace("Error loading XML.");
}
};
Note: You are loading XML data from an external file in this ActionScript. For information on
loading external data, see
Save the file as news_xml.fla in the same folder as myStory.txt.
10.
Run the movie (Control > Test Movie) to see the styles automatically applied to the text in
11.
the text field.

Using HTML-formatted text

Flash Player supports a subset of standard HTML tags such as
style text in any dynamic or input text field. Text fields in Flash Player 7 and later also support the
tag, which lets you embed JPEG files, SWF files, and movie clips in a text field. Flash
<img>
Player automatically wraps text around images embedded in text fields in much the same way that
a web browser wraps text around embedded images in an HTML page. For more information, see
"Embedding images, SWF files, and movie clips in text fields" on page
Flash Player also supports the
styles of the TextFormat class to HTML-enabled text fields. For more information, see
TextFormat class" on page
236
Chapter 9: Working with Text
Chapter 12, "Working with External Media," on page
tag, which lets you apply paragraph formatting
<textformat>
224.
styleSheet
295.
and
that you can use to
<p>
<li>
242.
"Using the

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents