EasyManua.ls Logo

MACROMEDIA FLASH 8-USING FLASH - Page 187

MACROMEDIA FLASH 8-USING FLASH
678 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...
Controlling text with ActionScript 187
First you must create a new TextFormat object. Then you can use the methods of the
TextField object and pass them the TextFormat object as a parameter to format the text in a
field.
Each character in a text field may individually be assigned a TextFormat object. The
TextFormat object of the first character of a paragraph is examined to perform paragraph
formatting for the entire paragraph.
To format text dynamically:
1. Select Window > Actions to open the Actions panel if it isn’t already open.
2. Do one of the following to create a text field:
Use the Text tool to create a text field on the Stage. Assign the text field an instance
name in the Property inspector.
For this example, enter the instance name myText.
Use the createTextField method of the MovieClip object. See “Creating text
on page 162. For this example, enter the instance name myText as a parameter of the
createTextField method.
3. Do one of the following to place text in the text field:
Enter text into the text field on the Stage.
Set the text property of the TextField object. See “Creating text” on page 162.
In the Actions toolbox, select the Built-in classes category, then select the Movie
category, and then select the TextFormat category. Finally, double-click
new
TextFormat
. For this example, enter myformat in the Object parameter field.
The following code is displayed in the Script pane:
myformat = new TextFormat();
4.
In the Actions toolbox, select the Built-in Classes category, then select the Movie category,
then select the TextFormat category, and then select the Properties category. Finally,
double-click
color. Repeat this step for the bullet and underline properties. The
following code is displayed in the Script pane:
myformat.color = 0xff0000;
myformat.bullet = true;
myformat.underline = true;
5.
In the Actions toolbox, select the Built-in Classes category, then select the Movie category,
then select the TextField category, and then select the Method category. Finally, double-
click
setTextFormat. For this example, enter myText in the Object parameter field.

Table of Contents

Related product manuals