Chapter 17 Example 7

by actionscriptbible
♥0 | Line 36 | Modified 2009-06-29 08:36:02 | MIT License
play

ActionScript3 source code

/**
 * Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/bnbd
 */

package {
  import flash.display.Sprite;
  import flash.text.TextField;
  import flash.text.TextFieldType;
  import flash.text.TextFormat;
  
  public class ch17ex7 extends Sprite {
    protected const INFMT:TextFormat = new TextFormat("_sans", 12, 0x505050);
    protected var nameTF:TextField;
    protected var phoneTF:TextField;
    protected var emailTF:TextField;

    public function ch17ex7() {
      nameTF = makeInputTextField();
      nameTF.text = "Your name";
      nameTF.maxChars = 40;
      
      phoneTF = makeInputTextField();
      phoneTF.text = "Your phone number";
      phoneTF.maxChars = 20;
      phoneTF.restrict = "0-9()\\-";
      
      emailTF = makeInputTextField();
      emailTF.text = "Your email address";
      emailTF.maxChars = 40;
      emailTF.restrict = "a-zA-Z0-9_\\-+=~!@#$%\\^.";
    }
    
    protected function makeInputTextField():TextField {
      var tf:TextField = new TextField();
      tf.type = TextFieldType.INPUT;
      tf.border = true;
      tf.defaultTextFormat = INFMT;
      tf.width = 300;
      tf.height = 18;
      tf.y = numChildren * 26;
      addChild(tf);
      return tf;
    }
  }
}

Forked