Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var phoneField:TextField = new TextField();
- with (phoneField) {
- type=TextFieldType.INPUT;
- maxChars=12;
- restrict="0-9";
- border=true;
- width=100;
- height=20;
- x=y=20;
- }
- addChild(phoneField);
- phoneField.addEventListener(TextEvent.TEXT_INPUT, onInput);
- function onInput(evt:TextEvent):void {
- if (phoneField.length==3 || phoneField.length==7) {
- phoneField.appendText("-");
- var leng:int=phoneField.text.length;
- phoneField.setSelection(leng, leng);
- }
- }
Add Comment
Please, Sign In to add comment