Mega Code Archive

 
Categories / Flex / Data Model
 

Switch format string for SwitchSymbolFormatter

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"   creationComplete="format()" backgroundColor="#FFFFFF">   <mx:Script>          import mx.formatters.SwitchSymbolFormatter;                          private function format():void {       var switchSymbolFormatter:SwitchSymbolFormatter = new SwitchSymbolFormatter();       formatted.text = switchSymbolFormatter.formatValue(formatString.selectedItem.toString(), unformatted.text);     }      </mx:Script>   <mx:Panel title="SwitchSymbolFormatter Example" width="400"     height="200">     <mx:Form>       <mx:FormItem label="Unformatted Data:">         <mx:TextInput id="unformatted" text="123456789" editable="false" />       </mx:FormItem>       <mx:FormItem label="Format String:">         <mx:ComboBox id="formatString" change="format()">           <mx:ArrayCollection>             <mx:String>##-###-####</mx:String>             <mx:String>(###)####-###</mx:String>           </mx:ArrayCollection>         </mx:ComboBox>       </mx:FormItem>       <mx:FormItem label="Formatted Data:">         <mx:TextInput id="formatted" editable="false" />       </mx:FormItem>     </mx:Form>   </mx:Panel> </mx:Application>