MACROMEDIA FLASH MX 2004-USING FLASH Use Manual page 126

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

Advertisement

Setting text field properties dynamically
To use ActionScript to set the properties of a text field, you must assign the text field an instance
name. If you create the text field on the Stage with the Text tool, you can assign the instance name
in the Property inspector. If you create the text field dynamically, you can assign an instance name
as a parameter of the
To set text field properties 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.
Select the Text tool and 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.
Double-click the
to add it to the Script pane in the Actions panel. See
example, enter the instance name myText as a parameter of the
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, then
4.
select the TextField category, and then select the Properties category. Finally, double-click the
multiline property.
Enter the following parameters:
5.
is the instance name of the text field whose property you want to set.
Object
is the value of the property.
Value
Repeat step 4 for the
6.
pane:
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = true;
For a complete list of TextField object methods and detailed descriptions of each, see "TextField
class" in Flash ActionScript Language Reference.
Formatting text dynamically
You can use the ActionScript TextFormat object to set properties of a text field. A TextFormat
object incorporates character and paragraph formatting information. Character formatting
information describes the appearance of individual characters: font name, point size, color, and an
associated URL. Paragraph formatting information describes the appearance of a paragraph: left
margin, right margin, indention of the first line, and left, right, or center alignment.
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.
126
Chapter 6: Working with Text
createTextField
createTextField
property of the TextField object. See
and
wordWrap
border
method.
method of the MovieClip object in the Actions toolbox
"Creating text" on page
"Creating text" on page
properties. The following code appears in the Script
108. For this
method.
createTextField
108.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents