| Package | mx.formatters |
| Class | public class ZipCodeFormatter |
| Inheritance | ZipCodeFormatter Formatter Object |
formatString property의 설정에 근거해, 유효한 수치를 다음의 몇개의 형식에 포맷 합니다.
6 자리수의 마스크에는 6 자리수의 수치를 설정할 필요가 있습니다. 5 자리수 또는 9 자리수의 마스크를 사용하고 있는 경우는, 5 자리수 또는 9 자리수의 수치를 사용해 포맷 할 수 있습니다.
에러가 발생하면, empty의 string가 돌려주어져 에러를 설명하는 string가 error property에 보존됩니다. 이 error property로 지정할 수 있는 값은, 다음 가운데 머지않아인가입니다.
"Invalid value" 는, 무효인 수치가 format() Methods에게 건네진 것을 나타냅니다. 값은, Number 형 또는 String 형의 유효한 수치일 필요가 있습니다. 다만, 캐나다의 우편 번호의 경우는 영숫자의 값을 사용할 수 있습니다. 또는, 자리수가 formatString property로 허가한 자리수로 일치하지 않습니다. "Invalid format" 는,formatString property의 임의의 캐릭터가 validFormatChars property로 지정된 캐릭터와 일치하지 않는, 또는 수치 플레이스홀더-의 수가 9 개, 5 개, 6 개의 머지않아도 아닌 것을 나타냅니다.
MXML 문장구조법의 비표시
The <mx:ZipCodeFormatter> 태그는, Super 클래스의 모든 태그 속성을 Inheritance해, 다음의 태그 속성을 추가합니다.
<mx:ZipCodeFormatter formatString="#####|#####-####|### ###" />
See also
| property | 정의 | ||
|---|---|---|---|
![]() | constructor : Object
특정의 object 인스턴스의 클래스 object 또는 constructor 함수에의 참조입니다.
| Object | |
![]() | error : String
에러가 발생했을 때에 Formatter에 의해 보존되는 설명을 나타냅니다.
| Formatter | |
| formatString : String
마스크 패턴을 나타냅니다.
| ZipCodeFormatter | ||
![]() | prototype : Object
[static]
클래스 또는 함수 object의 prototype object에의 참조입니다.
| Object | |
| Methods | 정의 | ||
|---|---|---|---|
| ZipCodeFormatter ()
constructor .
| ZipCodeFormatter | ||
| format (value:Object ):String
지정의 포맷을 사용해, string를 포맷 합니다.
| ZipCodeFormatter | ||
![]() | hasOwnProperty (name:String ):Boolean
object로 지정된 property가 정의되고 있는지 어떤지를 나타냅니다.
| Object | |
![]() | isPrototypeOf (theClass:Object ):Boolean
Object 클래스의 인스턴스가, Parameters로서 지정된 object의 prototype 체인내에 있을지 어떨지를 나타냅니다.
| Object | |
![]() | propertyIsEnumerable (name:String ):Boolean
지정된 property가 존재해, 열거 가능한가 어떤가를 나타냅니다.
| Object | |
![]() | setPropertyIsEnumerable (name:String , isEnum:Boolean = true):void
루프 처리에 대한 다이나믹 property의 가용성을 설정합니다.
| Object | |
![]() | toString ():String
지정된 object의 string 표현을 돌려줍니다.
| Object | |
![]() | valueOf ():Object
지정된 object의 원시적치를 돌려줍니다.
| Object | |
| formatString | property |
formatString:String [read-write]
마스크 패턴을 나타냅니다. 유효한 값은,"#####-####","##### ####","#####","###-###", 및 "### ###" 입니다.
디폴트치"#####".
public function get formatString():String
public function set formatString(value:String ):void
| ZipCodeFormatter | () | constructor |
public 함수 ZipCodeFormatter()constructor .
| format | () | Methods |
public override function format(value:Object ):String
지정의 포맷을 사용해, string를 포맷 합니다. 값을 포맷 할 수 없는 경우, empty의 string가 돌려주어져error property에 에러의 설명이 기입해집니다.
value:Object — 포맷 하는 값을 나타냅니다.
|
String —
포맷 한 string를 나타냅니다. 에러가 발생했을 경우는 empty입니다. 에러 상태를 나타내는 설명이 error property에 기입해집니다.
|
<? xml version="1.0" encoding="utf-8"? >
<! -- Simple example to demonstrate ZipCodeFormatter. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx: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= "";
}
}
]]>
</mx:Script>
<mx:ZipCodeFormatter id="zipFormatter" formatString="#####-####"/>
<mx:ZipCodeValidator id="zcVal" source="{zip}" property="text" allowedFormatChars=""/>
<mx:Panel title="ZipCodeFormatter Example" width="75%" height="75%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:Form width="100%">
<mx:FormItem label="Enter a 5 or 9 digit U.S. ZIP code:" width="100%">
<mx:TextInput id="zip" text=""/>
</mx:FormItem>
<mx:FormItem label="Formatted ZIP code: " width="100%">
<mx:TextInput id="formattedZipcode" text="" editable="false"/>
</mx:FormItem>
<mx:FormItem>
<mx:Button label="Validate and Format" click="Format();"/>
</mx:FormItem>
</mx:Form>
</mx:Panel>
</mx:Application>
코멘트가 추가되었을 경우, 메일로 받기. | 코멘트 리포트
현재의 페이지: http://flexdocs.kr/docs/flex2/langref/mx/formatters/ZipCodeFormatter.html