topical media & game development
explorer-formatters-SwitchSymbolFormatterExample.mx
explorer-formatters-SwitchSymbolFormatterExample.mx
[swf]
flex
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate SwitchSymbolFormatter. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.formatters.SwitchSymbolFormatter;
import mx.events.ValidationResultEvent;
private var vResult:ValidationResultEvent;
// Event handler to validate and format input.
private function Format():void
{
vResult = scVal.validate();
if (vResult.type==ValidationResultEvent.VALID) {
var switcher:SwitchSymbolFormatter=new SwitchSymbolFormatter('#');
formattedSCNumber.text =
switcher.formatValue("Formatted Social Securty number: -##- ", scNum.text);
}
else {
formattedSCNumber.text= "";
}
}
]]>
</mx:Script>
<mx:SocialSecurityValidator id="scVal" source="{scNum}" property="text"/>
<mx:Panel title="SwitchSymbolFormatter Example" width="75%" height="75%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:Label text="Enter a 9 digit Social Security number with no separator characters:"/>
<mx:TextInput id="scNum" text="" maxChars="9" width="50%"/>
<mx:Button label="Validate and Format" click="Format();"/>
<mx:TextInput id="formattedSCNumber" editable="false" width="75%"/>
</mx:Panel>
</mx:Application>
(C) Æliens
27/08/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.