本文和大家重点讨论一下Flex日期格式化,在Flex中提供了非常丰富的Flex格式化功能,包括Flex货币格式化,Flex日期格式化,Flex数字格式化等,这里向大家介绍一下Flex日期格式化功能。
Flex日期格式化
在Flex中提供了非常丰富的Flex格式化功能,包括Flex货币格式化,Flex日期格式化,Flex数字格式化,Flex电话号码格式化,和Flex邮编格式化,这里我选用日期格式化做了一个小例子,来入一下门。
Xml代码
- <?xmlversionxmlversion="1.0"encoding="utf-8"?>
- <BR><mx:Applicationxmlns:mxmx:Applicationxmlns:mx="http://www.adobe.com/2006/mxml"layout="vertical">
- <BR><mx:Script>
- <BR><![CDATA[
- <BR>importmx.managers.FocusManager;
- <BR>importmx.controls.Alert;
- <BR>
- <BR>privatefunctionhandlerEvent(event:Event):void{
- <BR>if(mydateFile.text==''){
- <BR>Alert.show("请您先选择一个DATE值");
- <BR>mydateFile.setFocus();
- <BR>}else{
- <BR>mydateFormatter.formatString=mycom.selectedItem.data.toString();
- <BR>mydateFile.text=mydateFormatter.format(mydateFile.text);
- <BR>}
- <BR>}
- <BR>]]>
- <BR></mx:Script>
- <BR><mx:DateFormatteridmx:DateFormatterid="mydateFormatter"formatString="YY-MM-DD"error="不对"/>
- <BR><mx:VBoxwidthmx:VBoxwidth="100%"height="400">
- <BR><mx:HBoxwidthmx:HBoxwidth="100%">
- <BR><mx:DateFieldidmx:DateFieldid="mydateFile"formatString="DD/MM/YYYY"/>
- <BR><mx:ComboBoxidmx:ComboBoxid="mycom"labelField="label"change="handlerEvent(event);">
- <BR><mx:dataProvider>
- <BR><mx:Array>
- <BR><mx:Objectlabelmx:Objectlabel="2000-11-28"data="YYYY-MM-DD"/>
- <BR><mx:Objectlabelmx:Objectlabel="11-28-2000"data="MM-DD-YYYY"/>
- <BR></mx:Array>
- <BR></mx:dataProvider>
- <BR></mx:ComboBox>
- <BR></mx:HBox>
- <BR></mx:VBox>
- <BR></mx:Application>
- <BR>
- <?xmlversionxmlversion="1.0"encoding="utf-8"?>
- <mx:Applicationxmlns:mxmx:Applicationxmlns:mx="http://www.adobe.com/2006/mxml"layout="vertical">
- <mx:Script>
- <![CDATA[
- importmx.managers.FocusManager;
- importmx.controls.Alert;
- privatefunctionhandlerEvent(event:Event):void{
- if(mydateFile.text==''){
- Alert.show("请您先选择一个DATE值");
- mydateFile.setFocus();
- }else{
- mydateFormatter.formatString=mycom.selectedItem.data.toString();
- mydateFile.text=mydateFormatter.format(mydateFile.text);
- }
- }
- ]]>
- </mx:Script>
- <mx:DateFormatteridmx:DateFormatterid="mydateFormatter"formatString="YY-MM-DD"error="不对"/>
- <mx:VBoxwidthmx:VBoxwidth="100%"height="400">
- <mx:HBoxwidthmx:HBoxwidth="100%">
- <mx:DateFieldidmx:DateFieldid="mydateFile"formatString="DD/MM/YYYY"/>
- <mx:ComboBoxidmx:ComboBoxid="mycom"labelField="label"change="handlerEvent(event);">
- <mx:dataProvider>
- <mx:Array>
- <mx:Objectlabelmx:Objectlabel="2000-11-28"data="YYYY-MM-DD"/>
- <mx:Objectlabelmx:Objectlabel="11-28-2000"data="MM-DD-YYYY"/>
- </mx:Array>
- </mx:dataProvider>
- </mx:ComboBox>
- </mx:HBox>
- </mx:VBox>
- </mx:Application>
【编辑推荐】