(Preview)
Package | mx.formatters |
Class | public class Formatter |
Inheritance | Formatter ![]() |
Implements | IFormatter |
Subclasses | CurrencyFormatter, DateFormatter, NumberFormatter, PhoneFormatter, ZipCodeFormatter |
Language Version: | ActionScript 3.0 |
Product Version: | Flex 3 |
Runtime Versions: | Flash Player 9, AIR 1.1 |
format()
method.
MXML Syntax
The Formatter class defines the following tag attributes, which all of its subclasses inherit:
<mx:tagname Properties error="" />
More examples
Public Properties
Property | Defined By | ||
---|---|---|---|
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance. | Object |
Protected Properties
Property | Defined By |
---|
Public Methods
Method | Defined By | ||
---|---|---|---|
![]() |
Indicates whether an object has a specified property defined. | Object | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | |
![]() |
Indicates whether the specified property exists and is enumerable. | Object | |
![]() |
Sets the availability of a dynamic property for loop operations. | Object | |
![]() |
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | |
![]() |
Returns the string representation of the specified object. | Object | |
![]() |
Returns the primitive value of the specified object. | Object |
Protected Methods
Method | Defined By |
---|
Property Detail
Constructor Detail
Method Detail
Examples How to use this example
SimpleFormatterExample.mxml
<?xml version="1.0" encoding="utf-8"?> <!-- Simple example to demonstrate the Formatter class. --> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"> <fx:Script> <![CDATA[ // Event handler to format the input. private function Format():void { // The format() method returns the formatted String, // or an empty String if there is an error. var formattedVal:String = numberFormatter.format(inputVal.text); if (formattedVal.length == 0) { // If there is an error, the Format.error property // contains the reason. formattedNumber.text = numberFormatter.error; } else { formattedNumber.text = formattedVal; } } ]]> </fx:Script> <fx:Declarations> <mx:NumberFormatter id="numberFormatter" /> </fx:Declarations> <s:Panel title="NumberFormatter Example" width="75%" height="75%" horizontalCenter="0" verticalCenter="0"> <mx:Form left="10" right="10" top="10" bottom="10"> <mx:FormItem label="Enter number - a letter is invalid:"> <s:TextInput id="inputVal" text="" width="75%"/> </mx:FormItem> <mx:FormItem label="Formatted number: "> <s:TextInput id="formattedNumber" editable="false" width="75%"/> </mx:FormItem> <mx:FormItem> <s:Button label="Validate and Format" click="Format();"/> </mx:FormItem> </mx:Form> </s:Panel> </s:Application>
Wed Nov 21 2018, 06:34 AM -08:00