MACROMEDIA FLASH MX 2004-USING FLASH Use Manual page 127

Hide thumbs Also See for FLASH MX 2004-USING FLASH:
Table of Contents

Advertisement

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:
Select Window > Development Panels > Actions to open the Actions panel if it isn't
1.
already open.
Do one of the following to create a text field:
2.
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
on page
108. For this example, enter the instance name myText as a parameter of the
createTextField
Do one of the following to place text in the text field:
3.
Enter text into the text field on the Stage.
Set the
text
In the Actions toolbox, select the Built-in classes category, then select the Movie category,
and then select the TextFormat category. Finally, double-click
example, enter myformat in the Object parameter field.
The following code is displayed in the Script pane:
myformat = new TextFormat();
In the Actions toolbox, select the Built-in Classes category, then select the Movie category, then
4.
select the TextFormat category, and then select the Properties category. Finally, double-click
. Repeat this step for the
color
displayed in the Script pane:
myformat.color = 0xff0000;
myformat.bullet = true;
myformat.underline = true;
In the Actions toolbox, select the Built-in Classes category, then select the Movie category, then
5.
select the TextField category, and then select the Method category. Finally, double-click
setTextFormat
In the Object field, enter the name of the TextFormat object you created in step 3, myformat.
6.
The following code appears in the Script pane:
mytext.setTextFormat(myformat);
For more information, see "Using the TextFormat class" in Using ActionScript in Flash.
Using text field events to trigger scripts
You can use ActionScript to capture events that happen to text fields—for example, you can
determine whether a user has changed or scrolled the text. You can write ActionScript statements
that use these events to trigger scripts to run.
method of the MovieClip object. See
method.
property of the TextField object. See
bullet
. For this example, enter myText in the Object parameter field.
"Creating text" on page
and
properties. The following code is
underline
Controlling text with ActionScript
"Creating text"
108.
. For this
new TextFormat
127

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents