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




ActionScript 3. 0 Cookbook
ActionScript 3.0 Cookbook: Solutions for Flash Platform and Flex Application Developers
ISBN: 0596526954
EAN: 2147483647
Year: 2007
Pages: 351

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net