| パッケージ | mx.formatters | 
| クラス | public class ZipCodeFormatter | 
| 継承 | ZipCodeFormatter  Formatter  Object | 
| 言語バージョン: | ActionScript 3.0 | 
| 製品バージョン: | Flex 3 | 
| ランタイムバージョン: | Flash Player 9, AIR 1.1 | 
formatString プロパティの設定に基づいて、有効な数値を次のいずれかの形式にフォーマットします。
  
  - #####-####
- ##### ####
- #####
- ### ###(カナダ式)
6 桁のマスクには 6 桁の数値を設定する必要があります。 5 桁または 9 桁のマスクを使用している場合は、5 桁または 9 桁の数値を使用してフォーマットできます。
エラーが発生すると、空のストリングが返され、エラーを説明するストリングが error プロパティに保存されます。 この error プロパティに保存される可能性のある値は、次のうちのいずれかです。
- 
                     "Invalid value"は、無効な数値がformat()メソッドに渡されたことを示します。 値は、Number 型または String 型の有効な数値である必要があります。ただし、カナダの郵便番号の場合は英数字の値を使用できます。または、桁数がformatStringプロパティで許可した桁数と一致していません。
-  
                     "Invalid format"は、formatStringプロパティの任意の文字がvalidFormatCharsプロパティで指定された文字と一致しない、または数値プレースホルダーーの数が 9 つ、5 つ、6 つのいずれでもないことを示します。
 MXML シンタックスを隠す
MXML シンタックスを隠すThe <mx:ZipCodeFormatter> tag
  inherits all of the tag attributes of its superclass,
  and adds the following tag attributes:
  <mx:ZipCodeFormatter
    formatString="#####|#####-####|### ###"
  />
  
  
  関連する API エレメント
パブリックプロパティ
| プロパティ | 定義元 | ||
|---|---|---|---|
|  | constructor : Object 
	 指定されたオブジェクトインスタンスのクラスオブジェクトまたはコンストラクター関数への参照です。 | Object | |
|  | error : String 
	  エラーが発生したときにフォーマッターによって保存される説明を表します。 | Formatter | |
| formatString : String 
	  マスクパターンを表します。 | ZipCodeFormatter | ||
プロテクトプロパティ
パブリックメソッド 
| メソッド | 定義元 | ||
|---|---|---|---|
| 
	  コンストラクターです。 | ZipCodeFormatter | ||
| [オーバーライド] 
	  指定のフォーマットを使用して、ストリングをフォーマットします。 | ZipCodeFormatter | ||
|  | 
	 オブジェクトに指定されたプロパティが定義されているかどうかを示します。 | Object | |
|  | 
	 Object クラスのインスタンスが、パラメーターとして指定されたオブジェクトのプロトタイプチェーン内にあるかどうかを示します。 | Object | |
|  | 
	 指定されたプロパティが存在し、列挙できるかどうかを示します。 | Object | |
|  | 
     ループ処理に対するダイナミックプロパティの可用性を設定します。 | Object | |
|  | 
	 ロケール固有の規則に従って書式設定された、このオブジェクトのストリング表現を返します。 | Object | |
|  | 
	 指定されたオブジェクトのストリング表現を返します。 | Object | |
|  | 
	 指定されたオブジェクトのプリミティブな値を返します。 | Object | |
プロテクトメソッド 
プロパティの詳細
| formatString | プロパティ | 
コンストラクターの詳細
| ZipCodeFormatter | () | コンストラクター | 
public function ZipCodeFormatter()| 言語バージョン: | ActionScript 3.0 | 
| 製品バージョン: | Flex 3 | 
| ランタイムバージョン: | Flash Player 9, AIR 1.1 | 
コンストラクターです。
メソッドの詳細
| format | () | メソッド | 
override public function format(value:Object):String| 言語バージョン: | ActionScript 3.0 | 
| 製品バージョン: | Flex 3 | 
| ランタイムバージョン: | Flash Player 9, AIR 1.1 | 
	  指定のフォーマットを使用して、ストリングをフォーマットします。 値をフォーマットできない場合、空のストリングが返され、error プロパティにエラーの説明が書き込まれます。
	 
	  
パラメーター
| value:Object— フォーマットする値を表します。 | 
| String— フォーマットしたストリングを表します。 エラーが発生した場合は空です。 エラーの状態を示す説明がerrorプロパティに書き込まれます。 | 
例 この例の使用方法 
ZipCodeFormatterExample.mxml
<?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>
Tue Jun 12 2018, 10:34 AM Z
 MXML シンタックスを表示
MXML シンタックスを表示