User Guide

TextInput component 743
You can write ActionScript to control these and additional options for the TextInput component
using its properties, methods, and events. For more information, see TextInput class
on page 745.
Creating an application with the TextInput component
The following procedure explains how to add a TextInput component to an application while
authoring. In this example, the component is a password field with an event listener that
determines if the proper number of characters has been entered.
To create an application with the TextInput component:
1.
Drag a TextInput component from the Components panel to the Stage.
2.
In the Property inspector, do the following:
Enter the instance name passwordField.
Leave the text parameter blank.
Set the editable parameter to true.
Set the password parameter to true.
3.
Select Frame 1 in the Timeline, open the Actions panel, and enter the following code:
textListener = new Object();
textListener.handleEvent = function (evt){
if (evt.type == "enter"){
trace("You must enter at least 8 characters");
}
}
passwordField.addEventListener("enter", textListener);
This code sets up an enter event handler on the TextInput passwordField instance that verifies
that the user entered the proper number of characters.
4.
Once text is entered in the passwordField instance, you can get its value as follows:
var login = passwordField.text;
Customizing the TextInput component
You can transform a TextInput component horizontally while authoring and at runtime. While
authoring, select the component on the Stage and use the Free Transform tool or any of the
Modify > Transform commands. At runtime, use
UIObject.setSize() or any applicable
properties and methods of the Tex tIn pu t c la s s .
When a TextInput component is resized, the border is resized to the new bounding box. The
TextInput component doesnt use scroll bars, but the insertion point scrolls automatically as the
user interacts with the text. The text field is then resized within the remaining area; there are no
fixed-size elements in a TextInput component. If the TextInput component is too small to display
the text, the text is clipped.