Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 210

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

You can use this formatter in a Flex application, as the following example shows:
<?xml version="1.0" ?>
<!-- formatters/FormatterSimple.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myFormatters.*">
<!-- Declare a formatter and specify formatting properties. -->
<MyComp:SimpleFormatter id="upperFormat" myFormatString="upper" />
<!-- Trigger the formatter while populating a string with data. -->
<mx:TextInput id="myTI" />
<mx:TextArea text="Your uppercase string is
{upperFormat.format(myTI.text)}" />
</mx:Application>
The namespace declaration in the
when referencing the formatter, and the location of the formatter's ActionScript file. That file
is in the myFormatters subdirectory of the application, or in the default classpath of the
application. For more information on deploying your formatters, see
Components," on page
Handling errors in formatters
For all formatter classes, except for the
the formatter returns an empty string and writes a string that describes the error condition to
the formatter's
error
superclass.
In your application, you can test for an empty string in the result returned by the formatter. If
detected, you can check the
example that handles a formatter error, see Chapter 41, "Formatting Data," in Flex 2
Developer's Guide. For more information on the SwitchSymbolFormatter class, see
SwitchSymbolFormatter class" on page
210
Creating Custom Formatters
<mx:Application>
63.
SwitchSymbolFormatter
property. The
error
property to determine the cause of the error. For an
error
211.
tag specifies to use the
class, when an error occurs,
property is inherited from the
prefix
MyComp
Chapter 6, "Compiling
Formatter
"Using the

Advertisement

Table of Contents
loading

Table of Contents