3 回答
TA贡献1843条经验 获得超7个赞
<mx:DateChooser change="date1_changeHandler(DateChooser(event.target).selectedDate" />
DateChooser(event.target) 这句改成 (event.target as DateChooser).selectedDate;
试一下
TA贡献1852条经验 获得超1个赞
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
protected function date1_changeHandler(date:Date):void
{
label_1.text = "date:" + date.getFullYear();
}
]]>
</mx:Script>
<mx:VBox>
<mx:DateChooser change="date1_changeHandler((event.target as DateChooser).selectedDate)" />
<mx:Label id="label_1" text="date:" />
</mx:VBox>
</mx:Canvas>
</mx:Application>
这是你要的代码
TA贡献1818条经验 获得超8个赞
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:layout>
<s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/>
</s:layout>
<fx:Script>
<![CDATA[
public function getCurrentDate(event:Event):void
{
result.text = '';
result.text+= (event.target.selectedDate as Date).getFullYear().toString();
}
]]>
</fx:Script>
<mx:DateChooser change="getCurrentDate(event)"/><s:Label text="当前年份是:" id="result"/>
</s:Application>
测试过没问题
添加回答
举报