Create an instance of a PhoneFormatter using ActionScript
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> import mx.formatters.*; [Bindable] public var rawPhone:String = "2223333"; public function formatThis(plainText:String):String { var fmtPhone:PhoneFormatter = new PhoneFormatter(); if(plainText.length == 7) fmtPhone.formatString = "###-####"; else fmtPhone.formatString = "###-###-####"; return(fmtPhone.format(plainText)); } </mx:Script> <mx:Label text="{formatThis(rawPhone)}" /> </mx:Application>