User Guide

Using the TextFormat class 225
5.
Apply the TextFormat object to the text field you created in step 1 using
TextField.setTextFormat():
myText_txt.setTextFormat(txtfmt);
This version of setTextFormat() applies the specified formatting to the entire text field.
There are two other versions of this method that let you apply formatting to individual
characters or groups of characters. For example, the following code applies bold, italic, 24-
point formatting to the first three characters you entered in the text field:
myText_txt.setTextFormat(0, 3, txtfmt);
For more information, see TextField.setTextFormat() in Flash ActionScript Language
Reference.
6.
Select Control > Test Movie to test the application.
For more information on using the TextFormat class, see the following topics:
“Default properties of new text fields” on page 225
“Getting text metric information” on page 226
Default properties of new text fields
Text fields created at runtime with
createTextField() receive a default TextFormat object with
the following properties:
font = "Times New Roman"
size = 12
textColor = 0x000000
bold = false
italic = false
underline = false
url = ""
target = ""
align = "left"
leftMargin = 0
rightMargin = 0
indent = 0
leading = 0
bullet = false
tabStops = [] (empty array)
Note: The default font property on the Mac OS X is Times.
For a complete list of TextFormat methods and their descriptions, see “TextFormat class” in Flash
ActionScript Language Reference.