Declare validators in ActionScript
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> import mx.validators.PhoneNumberValidator; private var v:PhoneNumberValidator = new PhoneNumberValidator(); private function createValidator():void { v.source = phoneInput; v.property = "text"; } </mx:Script> <mx:TextInput id="phoneInput" creationComplete="createValidator();" /> <mx:TextInput id="zipCodeInput" /> </mx:Application>