Pacotemx.formatters
Classepublic class Formatter
HerançaFormatter Inheritance Object
Subclasses CurrencyFormatter, DateFormatter, NumberFormatter, PhoneFormatter, ZipCodeFormatter

The Formatter class is the base class for all data formatters. Any subclass of Formatter must override the format() method.

Sintaxe em MXMLexpandedHide MXML Syntax

The Formatter class defines the following tag attributes, which all of its subclasses inherit:

  <mx:tagname
    Properties
    error=""
  />
  

Veja Exemplos



Propriedades Públicas
 PropriedadeDefinido por
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  defaultInvalidFormatError : String
[static] Error message for an invalid format string specified to the formatter.
Formatter
  defaultInvalidValueError : String
[static] Error messages for an invalid value specified to the formatter.
Formatter
  error : String
Descrição saved by the formatter when an error occurs.
Formatter
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Propriedades Protegidas
 PropriedadeDefinido por
  resourceManager : IResourceManager
[write-only] A reference to the object which manages all of the application's localized resources.
Formatter
Métodos Públicos
 MétodoDefinido por
  
Constructor.
Formatter
  
Formats a value and returns a String containing the new, formatted, value.
Formatter
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Métodos Protegidos
 MétodoDefinido por
  
This method is called when a Formatter is constructed, and again whenever the ResourceManager dispatches a "change" Event to indicate that the localized resources have changed in some way.
Formatter
Detalhes da propriedade
defaultInvalidFormatErrorpropriedade
defaultInvalidFormatError:String  [read-write]

Error message for an invalid format string specified to the formatter.

The default value is "Invalid format".


Implementação
    public static function get defaultInvalidFormatError():String
    public function set defaultInvalidFormatError(value:String):void
defaultInvalidValueErrorpropriedade 
defaultInvalidValueError:String  [read-write]

Error messages for an invalid value specified to the formatter.

The default value is "Invalid value".


Implementação
    public static function get defaultInvalidValueError():String
    public function set defaultInvalidValueError(value:String):void
errorpropriedade 
public var error:String

Descrição saved by the formatter when an error occurs. For the possible values of this property, see the description of each formatter.

Subclasses must set this value in the format() method.

resourceManagerpropriedade 
resourceManager:IResourceManager  [write-only]

A reference to the object which manages all of the application's localized resources. This is a singleton instance which implements the IResourceManager interface.

This property can be used as the source for data binding.


Implementação
    protected function set resourceManager(value:IResourceManager):void
Detalhes do construtor
Formatter()Construtor
public function Formatter()

Constructor.

Detalhes do método
format()método
public function format(value:Object):String

Formats a value and returns a String containing the new, formatted, value. All subclasses must override this method to implement the formatter.

Parâmetros

value:Object — Value to be formatted.

Retorna
String — The formatted string.
resourcesChanged()método 
protected function resourcesChanged():void

This method is called when a Formatter is constructed, and again whenever the ResourceManager dispatches a "change" Event to indicate that the localized resources have changed in some way.

This event will be dispatched when you set the ResourceManager's localeChain property, when a resource module has finished loading, and when you call the ResourceManager's update() method.

Subclasses should override this method and, after calling super.resourcesChanged(), do whatever is appropriate in response to having new resource values.

Exemplos How to use examples
SimpleFormatterExample.mxml
<?xml version="1.0"?>
<!-- Simple exemplo to demonstrate the Formatter class. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx: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;
                }
            }
        ]]>
    </mx:Script>

    <mx:NumberFormatter id="numberFormatter"/>

    <mx:Panel title="NumberFormatter Example" width="75%" height="75%" 
            paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">

        <mx:Form>
            <mx:FormItem label="Enter number - a letter is invalid:">
                <mx:TextInput id="inputVal" text="" width="75%"/>
            </mx:FormItem>

            <mx:FormItem label="Formatted number: ">
                <mx:TextInput id="formattedNumber" editable="false" width="75%"/>
            </mx:FormItem>

            <mx:FormItem>
                <mx:Button label="Validate and Format" click="Format();"/>
            </mx:FormItem>
        </mx:Form>
  
    </mx:Panel>
</mx:Application>