Flex中如何通过formatString属性对DateField控件字符串进行格式化的例子

By Minidxer | July 24, 2008

接下来的例子演示了MXML和ActionScript中如何通过formatString属性,对DateField控件字符串进行格式化。

让我们先来看一下Demo可以右键View Source或点击这里察看源代码):


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3.         layout="vertical"
  4.         verticalAlign="top"
  5.         backgroundColor="white">
  6.  
  7.     <mx:ApplicationControlBar dock="true">
  8.         <mx:Form styleName="plain">
  9.             <mx:FormItem label="formatString:" direction="horizontal">
  10.                 <mx:Button label="YYYY/MM/DD"
  11.                         click="dateField.formatString='YYYY/MM/DD';" />
  12.                 <mx:Button label="MM/DD/YYYY"
  13.                         click="dateField.formatString='MM/DD/YYYY';" />
  14.                 <mx:Button label="DD/MM/YYYY"
  15.                         click="dateField.formatString='DD/MM/YYYY';" />
  16.             </mx:FormItem>
  17.         </mx:Form>
  18.     </mx:ApplicationControlBar>
  19.  
  20.     <mx:DateField id="dateField"
  21.             formatString="YYYY-MM-DD" />
  22.  
  23. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:minidxer

Topics: Flex | Tags: , , , , ,

Search Posts

Archives

Sponsored Ads