| Pakket | mx.formatters |
| Klasse | public class ZipCodeFormatter |
| Overerving | ZipCodeFormatter Formatter Object |
| Taalversie: | ActionScript 3.0 |
| Productversie: | Flex 3 |
| Runtimeversies: | Flash Player 9, AIR 1.1 |
formatString property.
- #####-####
- ##### ####
- #####
- ### ### (Canadian)
A six-digit number must be supplied for a six-digit mask. If you use a five-digit or a nine-digit mask, you can use either a five-digit or a nine-digit number for formatting.
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:
-
"Invalid value"means an invalid numeric value is passed to theformat()method. The value should be a valid number in the form of a Number or a String, except for Canadian postal code, which allows alphanumeric values, or the number of digits does not match the allowed digits from theformatStringproperty. -
"Invalid format"means any of the characters in theformatStringproperty do not match the allowed characters specified in thevalidFormatCharsproperty, or the number of numeric placeholders does not equal 9, 5, or 6.
MXML-syntaxis verbergenThe <mx:ZipCodeFormatter> tag
inherits all of the tag attributes of its superclass,
and adds the following tag attributes:
<mx:ZipCodeFormatter
formatString="#####|#####-####|### ###"
/>
Verwante API-elementen
| Eigenschap | Gedefinieerd door | ||
|---|---|---|---|
![]() | constructor : Object
Verwijzing naar het klasseobject of de constructorfunctie van een bepaalde objectinstantie. | Object | |
![]() | error : String
Description saved by the formatter when an error occurs. | Formatter | |
| formatString : String
The mask pattern. | ZipCodeFormatter | ||
| Methode | Gedefinieerd door | ||
|---|---|---|---|
Constructor. | ZipCodeFormatter | ||
[overschrijven]
Formats the String by using the specified format. | ZipCodeFormatter | ||
![]() |
Geeft aan of voor een object een opgegeven eigenschap is gedefinieerd. | Object | |
![]() |
Geeft aan of een instantie van de klasse Object zich in de prototypeketen van het object bevindt dat als parameter is opgegeven. | Object | |
![]() |
Geeft aan of de opgegeven eigenschap bestaat en kan worden opgesomd. | Object | |
![]() |
Stelt de beschikbaarheid van een dynamische eigenschap voor lusbewerkingen in. | Object | |
![]() |
Geeft de tekenreeksweergave van dit object weer, geformatteerd volgens de locatiespecifieke conventies. | Object | |
![]() |
Retourneert een tekenreeksrepresentatie van het opgegeven object. | Object | |
![]() |
Retourneert de primitieve waarde van het opgegeven object. | Object | |
formatString | eigenschap |
formatString:String| Taalversie: | ActionScript 3.0 |
| Productversie: | Flex 3 |
| Runtimeversies: | Flash Player 9, AIR 1.1 |
The mask pattern.
Possible values are "#####-####",
"##### ####", "#####",
"###-###" and "### ###".
De standaardwaarde is "#####".
Implementatie
public function get formatString():String public function set formatString(value:String):voidZipCodeFormatter | () | Constructor |
public function ZipCodeFormatter()| Taalversie: | ActionScript 3.0 |
| Productversie: | Flex 3 |
| Runtimeversies: | Flash Player 9, AIR 1.1 |
Constructor.
format | () | methode |
override public function format(value:Object):String| Taalversie: | ActionScript 3.0 |
| Productversie: | Flex 3 |
| Runtimeversies: | Flash Player 9, AIR 1.1 |
Formats the String by using the specified format.
If the value cannot be formatted, return an empty String
and write a description of the error to the error property.
Parameters
value:Object — Value to format.
|
String — Formatted String. Empty if an error occurs. A description
of the error condition is written to the error property.
|
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate ZipCodeFormatter. -->
<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[
import mx.events.ValidationResultEvent;
private var vResult:ValidationResultEvent;
// Event handler to validate and format input.
private function Format():void {
vResult = zcVal.validate();
if (vResult.type == ValidationResultEvent.VALID) {
formattedZipcode.text = zipFormatter.format(zip.text);
} else {
formattedZipcode.text = "";
}
}
]]>
</fx:Script>
<fx:Declarations>
<mx:ZipCodeFormatter id="zipFormatter" formatString="#####-####"/>
<mx:ZipCodeValidator id="zcVal" source="{zip}" property="text" allowedFormatChars=""/>
</fx:Declarations>
<s:Panel title="ZipCodeFormatter Example"
width="75%" height="75%"
horizontalCenter="0" verticalCenter="0">
<mx:Form left="10" right="10" top="10" bottom="10">
<mx:FormItem label="Enter a 5 or 9 digit U.S. ZIP code:" width="100%">
<s:TextInput id="zip" text=""/>
</mx:FormItem>
<mx:FormItem label="Formatted ZIP code: " width="100%">
<s:TextInput id="formattedZipcode" text="" editable="false"/>
</mx:FormItem>
<mx:FormItem>
<s:Button label="Validate and Format" click="Format();"/>
</mx:FormItem>
</mx:Form>
</s:Panel>
</s:Application>
Wed Jun 13 2018, 11:42 AM Z
MXML-syntaxis weergeven