|
Flash CS4 Resources |
Use the TextArea componentThe TextArea component is a wrapper for the native ActionScript TextField object. You can use the TextArea component to display text and also to edit and receive text input if the editable property is true . The component can display or receive multiple lines of text and wraps long lines of text if the wordWrap property is set to true . The restrict property allows you to restrict the characters that a user can enter and maxChars allows you to specify the maximum number of characters that a user can enter. If the text exceeds the horizontal or vertical boundaries of the text area, horizontal and vertical scroll bars automatically appear unless their associated properties, horizontalScrollPolicy and verticalScrollPolicy , are set to off . You can use a TextArea component wherever you need a multiline text field. For example, you could use a TextArea component as a comment field in a form. You could set up a listener that checks whether the field is empty when a user tabs out of the field. That listener could display an error message indicating that a comment must be entered in the field. If you need a single-line text field, use the TextInput component. You can set the textFormat style using the setStyle() method to change the style of text that appears in a TextArea instance. You can also format a TextArea component with HTML using the htmlText property in ActionScript, and you can set the displayAsPassword property to true to mask text with asterisks. If you set the condenseWhite property to true , Flash removes extra white space in new text that is due to spaces, line breaks, and so on. It has no effect on text that is already in the control. User interaction with the TextArea componentA TextArea component can be enabled or disabled in an application. In the disabled state, it cannot receive mouse or keyboard input. When enabled, it follows the same focus, selection, and navigation rules as an ActionScript TextField object. When a TextArea instance has focus, you can control it using the following keys:
For more information about controlling focus, see the FocusManager class in the ActionScript 3.0 Language and Components Reference and Work with FocusManager. TextArea component parametersYou can set the following authoring parameters for each TextArea component instance in the Property inspector or the Component inspector: condenseWhite , editable , hortizontalScrollPolicy , maxChars , restrict , text , verticalScrollPolicy , and wordwrap . Each of these parameters has a corresponding ActionScript property of the same name. For information on the possible values for these parameters, see the TextArea class in the ActionScript 3.0 Language and Components Reference . A live preview of each TextArea instance reflects changes made to parameters in the Property inspector or Component inspector during authoring. If a scroll bar is needed, it appears in the live preview, but it does not function. Text is not selectable in the live preview, and you cannot enter text in the component instance on the Stage. You can write ActionScript to control these and additional options for the TextArea component using its properties, methods, and events. For more information, see the TextArea class in the ActionScript 3.0 Language and Components Reference . Create an application with the TextArea componentThe following procedure explains how to add a TextArea component to an application while authoring. The example sets up a focusOut event handler on the TextArea instance that verifies that the user typed something in the text area before giving focus to a different part of the interface.
Create a TextArea instance using ActionScriptThe following example creates a TextArea component with ActionScript. It sets the condenseWhite property to true to condense white space and assigns text to the htmlText property to take advantage of HTML text formatting attributes.
|