topical media & game development
professional-flex-code-15-SwitchSymbol2.mx
professional-flex-code-15-SwitchSymbol2.mx
[swf]
flex
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="format()" backgroundColor="#FFFFFF">
<mx:Script>
<![CDATA[
import mx.formatters.SwitchSymbolFormatter;
private function format():void {
// Create Instance of the SwitchSymbolFormatter and pass in mask character
var switchSymbolFormatter:SwitchSymbolFormatter = new SwitchSymbolFormatter("*");
// Apply formatter on the unformatted TextInput data using selectedItem from ComboBox
formatted.text = switchSymbolFormatter.formatValue(formatString.selectedItem..toString(), unformatted.text);
}
]]>
</mx:Script>
<mx:Panel title="SwitchSymbolFormatter Example" width="400" height="200"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<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: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>
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.