Flex中如何通过formatString属性对DateField控件字符串进行格式化的例子
By Minidxer | July 24, 2008
接下来的例子演示了MXML和ActionScript中如何通过formatString属性,对DateField控件字符串进行格式化。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
Download: main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="top"
- backgroundColor="white">
- <mx:ApplicationControlBar dock="true">
- <mx:Form styleName="plain">
- <mx:FormItem label="formatString:" direction="horizontal">
- <mx:Button label="YYYY/MM/DD"
- click="dateField.formatString='YYYY/MM/DD';" />
- <mx:Button label="MM/DD/YYYY"
- click="dateField.formatString='MM/DD/YYYY';" />
- <mx:Button label="DD/MM/YYYY"
- click="dateField.formatString='DD/MM/YYYY';" />
- </mx:FormItem>
- </mx:Form>
- </mx:ApplicationControlBar>
- <mx:DateField id="dateField"
- formatString="YYYY-MM-DD" />
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:minidxer
Topics:
Flex |
Tags: ActionScript, DateField, formatString, MXML, 字符串, 格式化