|
Flash CS4 Resources |
Use the TextInput componentThe TextInput component is a single-line text component that is a wrapper for the native ActionScript TextField object. If you need a multiline text field, use the TextArea component. For example, you could use a TextInput component as a password field in a form. You could also set up a listener that checks whether the field has enough characters when a user tabs out of the field. That listener could display an error message indicating that the proper number of characters must be entered. You can set the textFormat property using the setStyle() method to change the style of text that appears in a TextInput instance. A TextInput component can also be formatted with HTML or as a password field that disguises the text. User interaction with the TextInput componentA TextInput component can be enabled or disabled in an application. In the disabled state, it doesn’t receive mouse or keyboard input. When enabled, it follows the same focus, selection, and navigation rules as an ActionScript TextField object. When a TextInput instance has focus, you can also use the following keys to control it:
For more information about controlling focus, see the FocusManager class in the ActionScript 3.0 Language and Components Reference and Work with FocusManager. A live preview of each TextInput instance reflects changes made to parameters in the Property inspector or Component inspector during authoring. Text is not selectable in the live preview, and you cannot enter text in the component instance on the Stage. When you add the TextInput component to an application, you can use the Accessibility panel to make it accessible to screen readers. TextInput component parametersYou can set the following authoring parameters for each TextInput component instance in the Property inspector or the Component inspector: editable , displayAsPassword , maxChars , restrict , and text . Each of these parameters has a corresponding ActionScript property of the same name. For information on the possible values for these parameters, see the TextInput class in the ActionScript 3.0 Language and Components Reference . You can write ActionScript to control these and additional options for the TextInput component using its properties, methods, and events. For more information, see the TextInput class in the ActionScript 3.0 Language and Components Reference . Create an application with the TextInput componentThe following procedure explains how to add a TextInput component to an application. The example uses two TextInput fields to receive and confirm a password. It uses an event listener to see that a minimum of eight characters have been entered and that the text for the two fields matches.
Create a TextInput instance using ActionScriptThe following example creates a TextInput component using ActionScript. The example also creates a Label that it uses to prompt a user to enter his or her name. The example sets the component’s restrict property to allow only uppercase and lowercase letters, a period, and a space. It also creates a TextFormat object that it uses to format the text in both the Label and TextInput components.
|