
TextField.getTextFormat() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
840
|
ActionScript Language Reference
Any text added to a field via TextField.text, TextField.replaceSel(), or by the user is
formatted according to the settings of the object returned by getNewTextFormat(). For a
new text field, the default TextFormat object has the property values shown in Table R-25
under the Description heading for the TextFormat class entry.
The default values can be changed with setNewTextFormat(). However,
setNewTextFormat() does not format characters already in the field; it merely sets the
format for any future characters that are added. To reformat characters already in a text
field, use setTextFormat(). To examine the format of characters already in a text field, use
getTextFormat().
Usage
When the insertion point is placed in a text field by the user or with Selection.setSelection(),
the field’s new text format is set to match the character to the insertion point’s right (or
left, in the case of the last character). The return value of getNewTextFormat() will reflect
the format of that character. See the Example under TextField.setNewTextFormat() for
code that forces the new text format not to adopt the existing text’s format.
Example
The following code checks the default font size for a field named numbers_txt and then
increases ...