Prevent Default Test : Text event : TextField Flash / Flex / ActionScript examples


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

 

Prevent Default Test


 
package {
     
     import flash.display.Sprite;
     import flash.text.TextField;
     import flash.text.TextFieldType;
     import flash.events.TextEvent;
     
     [SWF(width=550, height=400)]

     public class Main extends Sprite {
     
          public function Main() {
               var tf:TextField = new TextField();
               addChild(tf);
               
               tf.width = stage.stageWidth;
               tf.height = stage.stageWidth;
               tf.type = TextFieldType.INPUT;
               tf.wordWrap = true;
               
               tf.addEventListener(TextEvent.TEXT_INPUT, onTextFieldTextInput);
          }
          
          private function onTextFieldTextInput(event:TextEvent):void {
               var tf:TextField = event.target as TextField;
               if (tf.text.indexOf(event.text> -1) {
                    event.preventDefault();
               }
          }
     
     }

}

        



Leave a Comment / Note


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


Flash / Flex / ActionScript examples

 Navioo TextField
» Text event