Recipe 8.17 Formatting User-Input Text

8.17.1 Problem

You want to apply formatting to text as it is entered into a text field by the user.

8.17.2 Solution

Apply a TextFormat object using the setNewTextFormat( ) method of the text field.

8.17.3 Discussion

You should use the setNewTextFormat( ) method of a text field object to apply text formatting to text as it is entered by the user. You should create a TextFormat object as in Recipe 8.16 and then pass that object to the text field's setNewTextFormat( ) method:

myTextFormat = new TextFormat(  ); myTextFormat.color = 0x0000FF;      // Make the text blue. myTextField.setNewTextFormat(myTextFormat);

When you use setNewTextFormat( ), the formatting is applied to text that the user types into the field.

8.17.4 See Also

Recipe 8.18



ActionScript Cookbook
ActionScript 3.0 Cookbook: Solutions for Flash Platform and Flex Application Developers
ISBN: 0596526954
EAN: 2147483647
Year: 2005
Pages: 425

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