topical media & game development

talk show tell print

professional-flex-code-13-EmailTextInput.ax

professional-flex-code-13-EmailTextInput.ax [swf] flex


  package 
  {
    import mx.controls.TextInput;  
    import mx.events.ValidationResultEvent;
    import mx.validators.EmailValidator;
    import flash.events.Event;
  
    public class @ax-professional-flex-code-13-EmailTextInput extends TextInput {
     
      private var emailValidator:EmailValidator = new EmailValidator();
      private var validator:ValidationResultEvent;
      
      public function @ax-professional-flex-code-13-EmailTextInput(){
        super();    
        this.addEventListener("change", this.validate);
        this.emailValidator.source = this;
        this.emailValidator.property = "text";
      }
      
      private function validate(event:Event):void{
        validator = emailValidator.validate();
        if (validator.type==ValidationResultEvent.VALID)                 {
          this.errorString="";
        } else {
          this.errorString = validator.message;
        }
      }
    }
  }
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.