Responding to User Text Entry : Text event : TextField Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » TextField » Text event »

 

Responding to User Text Entry


 

package {

  import flash.display.Sprite;
  import flash.text.TextField;
  import flash.text.TextFieldType;
  import flash.events.TextEvent;
  import flash.events.TextEvent;

  public class Main extends Sprite {

    private var _field:TextField = new TextField(  );

    public function Main(  ) {
      _field.border = true;
      _field.background = true;
      _field.type = TextFieldType.INPUT;
      addChild(_field);
      _field.addEventListener(TextEvent.TEXT_INPUT, onTextInput);
    }
    
    private function onTextInput(event:TextEvent):void {
      if(event.text == "a" && _field.length == 0) {
          event.preventDefault(  );
      }
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo TextField
» Text event