Recipe 9.14.
Formatting User-Input Text
Problem
You
want to apply formatting to text as
the user enters it into a text field.
Solution
Apply a TextFormat object by using
the defaultTextFormat
property of the text field.
Discussion
You should use the defaultTextFormat
property of a text field object to apply text formatting to text as
it is entered by user input. Create a TextFormat object as
in Recipe
9.13, and then assign that object to the text field's
defaultTextFormat property:
var formatter:TextFormat = new TextFormat( );
formatter.color = 0x0000FF; // Make the text blue
field.defaultTextFormat = formatter;
When you use defaultTextFormat, the
formatting is applied to text that the user types into the
field.
See Also
Recipes 9.13
and 9.15
|