猿问

我把这个DateChooser的组件放在主程序中则能够点出selectedDate这个属性。求解决!

主程序: 

Java代码 

<?xml version="1.0" encoding="utf-8"?>  

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"   

                backgroundGradientAlphas="[0x000000,0x00ffff]"  

                xmlns:dataEntryContorls="com.flexCoreComponents.uiContorls.dataEntryContorls.*" xmlns:local="*">  

      

    <dataEntryContorls:DateChooser />  

</mx:Application>  


CheckBox_flex3引用代码 

Java代码 

<?xml version="1.0" encoding="utf-8"?>  

<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(DateChooser(event.target).selectedDate" />  

        <mx:Label id="label_1" text="date:" />  

    </mx:VBox>  

          

</mx:Canvas>  


问题是date1_changeHandler(DateChooser(event.target).selectedDate中的selectedDate属性没有,这是为什么啊?


守候你守候我
浏览 101回答 3
3回答

蓝山帝景

<mx:DateChooser&nbsp; change="date1_changeHandler(DateChooser(event.target).selectedDate" />&nbsp;&nbsp;DateChooser(event.target) 这句改成 (event.target as DateChooser).selectedDate;&nbsp;试一下

小怪兽爱吃肉

<?xml version="1.0" encoding="utf-8"?>&nbsp;<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">&nbsp;<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">&nbsp;&nbsp;<mx:Script>&nbsp;&nbsp;<![CDATA[&nbsp;&nbsp;protected function date1_changeHandler(date:Date):void&nbsp;&nbsp;{&nbsp;&nbsp;label_1.text = "date:" + date.getFullYear();&nbsp;&nbsp;}&nbsp;&nbsp;]]>&nbsp;&nbsp;</mx:Script>&nbsp;&nbsp;<mx:VBox>&nbsp;&nbsp;<mx:DateChooser change="date1_changeHandler((event.target as DateChooser).selectedDate)" />&nbsp;&nbsp;<mx:Label id="label_1" text="date:" />&nbsp;&nbsp;</mx:VBox>&nbsp;&nbsp;</mx:Canvas>&nbsp;</mx:Application>&nbsp;这是你要的代码&nbsp;

弑天下

<?xml version="1.0" encoding="utf-8"?>&nbsp;<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"&nbsp;&nbsp;&nbsp; xmlns:s="library://ns.adobe.com/flex/spark"&nbsp;&nbsp;&nbsp; xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">&nbsp;<fx:Declarations>&nbsp;<!-- 将非可视元素(例如服务、值对象)放在此处 -->&nbsp;</fx:Declarations>&nbsp;<s:layout>&nbsp;<s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/>&nbsp;</s:layout>&nbsp;<fx:Script>&nbsp;<![CDATA[&nbsp;public function getCurrentDate(event:Event):void&nbsp;{&nbsp;result.text = '';&nbsp;result.text+= (event.target.selectedDate as Date).getFullYear().toString();&nbsp;}&nbsp;]]>&nbsp;</fx:Script>&nbsp;<mx:DateChooser change="getCurrentDate(event)"/><s:Label text="当前年份是:" id="result"/>&nbsp;</s:Application>&nbsp;&nbsp;测试过没问题
随时随地看视频慕课网APP

相关分类

Java
我要回答