EasyManua.ls Logo

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

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...
386 Working with Text and Strings
To create an HTML-formatted text field:
Use one of the following two steps to enable HTML formatting for the text field:
Select a text field and click Render Text as HTML in the Property inspector.
Set the text fields html property to true by using ActionScript (see the following
code sample).
To apply HTML formatting to a text field by using ActionScript, type the following
ActionScript on Frame 1 of the Timeline:
this.createTextField("headline_txt", this.getNextHighestDepth(), 100, 100,
300, 20);
headline_txt.html = true;
headline_txt.htmlText = "New articles available on <i>Developer Center</
i>.";
The preceding code dynamically creates a new text field, enables HTML formatting, and
displays the text “New articles available on Developer Center” on the Stage, with the word
“Developer Center” appearing in italics.
You can find sample source files that demonstrate how to work with text fields using
ActionScript. The source files are called textfieldsA.fla and textfieldsB.fla, and you can find
them in the Samples folder on your hard disk:
In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\TextFields.
On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/TextFields.
About text field instance and variable names
In the Instance Name text box in the Property inspector, you must assign an instance name to
a text field to invoke methods and get and set properties on that text field.
In the Var text box in the Property inspector, you can assign a variable name to a dynamic or
input text field. You can then assign values to the variable. This is a deprecated functionality
that you might use when you create applications for older versions of Flash Player (such as
Flash Player 4). When you target newer players, target the text of a text field by using its
instance name and ActionScript.
CAUTION
When you use HTML formatted text with a text field (not components) on the Stage, you
must assign the text to the text field’s
htmlText property instead of the text property.

Table of Contents

Related product manuals