User Guide
TextInput component 745
The TextArea and TextInput components both use the same styles and are often used in the same
manner. Thus, by default they share the same class-level style declaration. For example, the
following code sets a style on the TextArea declaration but it affects both TextArea and TextInput
components.
_global.styles.TextArea.setStyle("disabledColor", 0xBBBBFF);
To separate the components and provide class-level styles for one and not the other, create a new
style declaration.
import mx.styles.CSSStyleDeclaration;
_global.styles.TextInput = new CSSStyleDeclaration();
_global.styles.TextInput.setStyle("disabledColor", 0xFFBBBB);
Notice how this example does not check if _global.styles.TextInput existed before
overwriting it; in this example, you know it exists and you want to overwrite it.
Using skins with the TextInput component
The TextArea component uses an instance of RectBorder for its border. For more information
about skinning these visual elements, see “RectBorder class” on page 647.
TextInput class
Inheritance MovieClip > UIObject class > UIComponent class > TextInput
ActionScript Class Name mx.controls.TextInput
The properties of the TextInput class let you set the text content, formatting, and horizontal
position at runtime. You can also indicate whether the field is editable, and whether it is a
“password” field. You can also restrict the characters that a user can enter.
Setting a property of the TextInput class with ActionScript overrides the parameter of the same
name set in the Property inspector or Component inspector.
The TextInput component uses the Focus Manager to override the default Flash Player focus
rectangle and draw a custom focus rectangle with rounded corners. For more information, see
“FocusManager class” on page 419.
The TextInput component supports CSS styles and any additional HTML styles supported by
Flash Player. For information about CSS support, see the W3C specification at www.w3.org/TR/
REC-CSS2/.
You can manipulate the text string by using the string returned by the text object.
Each component class has a
version property, which is a class property. Class properties are
available only on the class itself. The
version property returns a string that indicates the version
of the component. To access this property, use the following code:
trace(mx.controls.TextInput.version);
Note: The code
trace(myTextInputInstance.version); returns undefined.