May 01
接下来的例子演示了Flex中如何通过监听open和
close事件,来判断DateField控件状态为opened还是closed。
让我们先来看一下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="middle"
- backgroundColor="white">
- <mx:Script>
- <![CDATA[
- import mx.events.DropdownEvent;
- private function dateField_openClose(evt:DropdownEvent):void {
- arrColl.addItem(evt);
- }
- ]]>
- </mx:Script>
- <mx:ArrayCollection id="arrColl" />
- <mx:ApplicationControlBar dock="true">
- <mx:DateField id="dateField"
- open="dateField_openClose(event);"
- close="dateField_openClose(event);" />
- </mx:ApplicationControlBar>
- <mx:DataGrid id="dataGrid"
- dataProvider="{arrColl}"
- itemRenderer="mx.controls.Label"
- width="100%"
- height="100%" />
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:minidxer
