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, indentation 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.
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:
createTextField
method of the MovieClip object. See Creating text in Using Flash. For this example, enter the instance name myText as a parameter of the createTextField
method.text
property of the TextField object. See Creating text in Using Flash.new TextFormat
. For this example, enter myformat in the Object parameter field. The following code is displayed in the Script pane:myformat = new TextFormat();
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;
setTextFormat
. For this example, enter myText in the Object parameter field.mytext.setTextFormat(myformat);
For a complete list of TextFormat object methods and detailed descriptions of each, see in ActionScript Dictionary.