Creating an application with the TextArea component

The 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.

To create an application with the TextArea component:

  1. Select File > New and choose Flash File (ActionScript 2.0).
  2. Drag a TextArea component from the Components panel to the Stage and give it an instance name of my_ta.
  3. Select Frame 1 in the Timeline, open the Actions panel, and enter the following code:
    /**
     Requires:
      - TextArea instance on Stage (instance name: my_ta)
    */
    
    var my_ta:mx.controls.TextArea;
    
    var taListener:Object = new Object();
    taListener.focusOut = function(evt_obj:Object) {
     if (my_ta.length < 1) {
      trace("Please enter a comment");
     }
    };
    my_ta.addEventListener("focusOut", taListener);
    

    This code sets up a focusOut event handler on the TextArea component instance that verifies that the user typed something in the text area.

You can get the value of text that is entered in the TextArea instance, as follows:

var ta_text:String = my_ta.text;