error="Invalid Format String";
return ""
}
// If the formatString and value are valid, format the number.
var dataFormatter:SwitchSymbolFormatter =
new SwitchSymbolFormatter();
return dataFormatter.formatValue( formatString, value );
}
}
}
The following example uses this custom formatter in an application:
<?xml version="1.0" encoding="UTF-8"?>
<!-- formatters/formatterSS.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myFormatters.*">
<!-- Declare a formatter and specify formatting properties. -->
<MyComp:CustomSSFormatter id="SSFormat"
formatString="SS: #-#-#-#-#-#-#-#-#"/>
<!-- Trigger the formatter while populating a string with data. -->
<mx:TextInput text="Your SS number is {SSFormat.format('123456789')}"/>
</mx:Application>
Using the SwitchSymbolFormatter class
213