Packageorg.apache.flex.formatters
Classpublic class PostCodeFormatter
InheritancePostCodeFormatter Inheritance Formatter Inheritance Object

Language Version : ActionScript 3.0
Product Version : ApacheFlex 4.8
Runtime Versions : AIR 1.0, Flash Player 10.2

The PostCodeFormatter class formats a valid postcode based on a user set formatString or formats property.

Postcode formats consists of the letters C, N, A and spaces or hyphens

Country codes one be one or two digits.

For example "NNNN" is a four digit numeric postcode, "CCNNNN" is country code followed by four digits and "AA NNNN" is two letters, followed by a space then followed by four digits.

More than one format can be specified by setting the formats property to an array of format strings.

Spaces and hypens will be added if missing to format the postcode correctly.

If an error occurs, an empty String is returned and a String that describes the error is saved to the error property. The error property can have one of the following values:

Fullwidth numbers and letters are supported in postcodes by ignoring character width via the flash.globalization.Collator equals method.

MXML SyntaxexpandedHide MXML Syntax

The <mx:PostCodeFormatter> tag inherits all of the tag attributes of its superclass, and adds the following tag attributes:

  <mx:PostCodeFormatter
    formatString="NNNNN"
    formats="['NNNNN', 'NNNNN-NNNN']"
  />
  

See also

org.apache.flex.validators.PostCodeValidator


Public Properties
 PropertyDefined By
 InheriteddefaultInvalidFormatError : String
[static] Error message for an invalid format string specified to the formatter.
Formatter
 InheriteddefaultInvalidValueError : String
[static] Error messages for an invalid value specified to the formatter.
Formatter
 Inheritederror : String
Description saved by the formatter when an error occurs.
Formatter
  formats : Array
An array of format strings to format the postcode in.
PostCodeFormatter
  formatString : String
Format string to format the postcode in.
PostCodeFormatter
Protected Properties
 PropertyDefined By
 InheritedresourceManager : IResourceManager
[read-only] A reference to the object which manages all of the application's localized resources.
Formatter
Public Methods
 MethodDefined By
  
Constructor.
PostCodeFormatter
  
format(value:Object):String
[override] Formats the value by using the format set in formatString or formats.
PostCodeFormatter
Protected Methods
 MethodDefined By
 Inherited
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
Property Detail
formatsproperty
formats:Array

Language Version : ActionScript 3.0
Product Version : ApacheFlex 4.8
Runtime Versions : AIR 1.0, Flash Player 10.2

An array of format strings to format the postcode in.

Use for locales where more than one format is required. eg en_UK

See formatString for format of the format strings.

The default value is [].


Implementation
    public function get formats():Array
    public function set formats(value:Array):void
formatStringproperty 
formatString:String

Language Version : ActionScript 3.0
Product Version : ApacheFlex 4.8
Runtime Versions : AIR 1.0, Flash Player 10.2

Format string to format the postcode in.

The format string consists of the letters C, N, A and spaces or hyphens:

The default value is null.


Implementation
    public function get formatString():String
    public function set formatString(value:String):void
Constructor Detail
PostCodeFormatter()Constructor
public function PostCodeFormatter()

Language Version : ActionScript 3.0
Product Version : ApacheFlex 4.8
Runtime Versions : AIR 1.0, Flash Player 10.2

Constructor.

Method Detail
format()method
override public function format(value:Object):String

Language Version : ActionScript 3.0
Product Version : ApacheFlex 4.8
Runtime Versions : AIR 1.0, Flash Player 10.2

Formats the value by using the format set in formatString or formats.

If the value cannot be formatted this method returns an empty String and write a description of the error to the error property.

Parameters

value:Object — Value to format.

Returns
String — Formatted String. Empty if an error occurs. A description of the error condition is written to the error property.