datefield的空对象引用错误

时间:2013-12-30 12:23:14

标签: actionscript-3 flex flex4

我有两个日期字段,一个是开始日期&另一个是结束日期。我必须发送日期以获取MySQL到PHP的两个日期之间的值。

第一次我得到的值是正确的,然后当我再次点击datefield时,我得到如下的错误对象空引用

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.controls::DateField/displayDropdown()[E:\dev\hero_private_beta\frameworks\projects\mx\src\mx\controls\DateField.as:2342]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\hero_private_beta\frameworks\projects\framework\src\mx\core\UIComponent.as:12064]
at mx.core::UIComponent/callLaterDispatcher()[E:\dev\hero_private_beta\frameworks\projects\framework\src\mx\core\UIComponent.as:12002]

&安培;这是我的代码

<mx:HBox visible="{duration.selectedValue == 'date'}" horizontalGap="0" includeInLayout="duration.selectedValue == 'date'}"> 
    <mx:Label text="From" styleName="Helvet12Normal818181" paddingTop="2"/> 
    <mx:DateField id="startdate" yearNavigationEnabled="true" height="20" styleName="Helvet12Normal818181"  disabledRanges="{[ {rangeEnd: new Date(2011, 12, 31)} ]}" formatString="MM/DD/YYYY" color="0x000000" editable="true" selectedDate="{stDate}" change="useDate(event)" parseFunction="{null}"/>
    <mx:Spacer width="8"/>
    <mx:Label text="To" styleName="Helvet12Normal818181" paddingTop="2"/>   
    <mx:DateField id="enddate" yearNavigationEnabled="true" height="20" formatString="MM/DD/YYYY" styleName="Helvet12Normal818181"  color="0x000000" editable="true" selectedDate="{enDate}" parseFunction="{null}"/>
    <mx:Button click="update_clickHandler()"/>                                  
</mx:HBox>  

这是我的动作脚本

protected function update_clickHandler():void
        {
             validateDates();
            if(validateDates())
            { 
                theOb = new Object();
                theOb["theTaskName"] = "GetSiteVisits";
                theOb["filterType"] =  "date";
                var df:DateFormatter = new DateFormatter();
                 df.formatString = "YYYY-MM-DD"; 


                var formattedStartDate:String=df.format(startdate.text);
                var formattedEndDate:String =df.format(enddate.text);

                theOb["start_date"]     = formattedStartDate;
                theOb["end_date"]       = formattedEndDate;  

                if(theModel.dashboardVO.activityID!=null)
                {
                    theOb["content_type"] = theModel.dashboardVO.activity_name;
                }
                else
                {
                    theOb["content_type"] = "watchvideo";
                }
                var theEvt:GetReportItemsEvent = new GetReportItemsEvent(theOb);
                theEvt.dispatch();
                theModel.tempAdminParams = theOb;
            } 
        }

0 个答案:

没有答案