Formatter components are ActionScript components that perform a one-way conversion of raw data to a formatted string. They are triggered just before data is displayed in a text field. Flex includes a set of standard formatters. You can also create your own formatters. The following example shows an application that uses the standard ZipCodeFormatter component to format the value of a variable:
<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"><!-- Declare a ZipCodeFormatter and define parameters. --><mx:ZipCodeFormatter id="ZipCodeDisplay" formatString="#####-####" /> <mx:Script> <![CDATA[ var storedZipCode=123456789; ]]> </mx:Script> <mx:Panel title="My Application" marginTop="10" marginBottom="10" marginLeft="10" marginRight="10" ><!-- Trigger the formatter while populating a string with data. --><mx:TextInput text="{ZipCodeDisplay.format(storedZipCode)}" /> </mx:Panel> </mx:Application>
The following figure shows the application rendered in a web browser window:
For more information about formatter components, see Formatting Data in Developing Flex Applications.
Version 1.5
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flex/15/flex_docs_en/00000022.htm
Comments
No screen name said on Aug 22, 2005 at 7:57 AM : danger42 said on Aug 22, 2005 at 8:44 AM :