
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.
Содержание FLASH 8-USING FLASH
Страница 1: ...Using Flash...
Страница 12: ...12 Contents...
Страница 110: ...110 Using Symbols Instances and Library Assets...
Страница 128: ...128 Working with Color Strokes and Fills...
Страница 156: ...156 Drawing...
Страница 190: ...190 Working with Text...
Страница 224: ...224 Working with Graphic Objects...
Страница 270: ...270 Creating Motion...
Страница 310: ...310 Working with Video...
Страница 362: ...362 Working with Screens Flash Professional Only...
Страница 386: ...386 Creating Multilanguage Text...
Страница 454: ...454 Data Integration Flash Professional Only...
Страница 500: ...500 Publishing...
Страница 534: ...534 Creating Accessible Content...