Flex 开始日期DateField与结束日期DateField组件

<?xml version="1.0" encoding="utf-8"?>  
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" backgroundGradientColors="[#ffffff, #ffffff]">  
        <mx:Script>  
                <![CDATA[  
                        import mx.controls.DateField;  
                          
                        [Bindable]  
                        private var today:Date = new Date(new Date().setHours(0,0,0,0));  
                        [Bindable]  
                        private var start:Date = today;  
                        [Bindable]  
                        private var end:Date = null;  
                          
                       	private var dateRange:Object = new Object();

                        /*DateChange*/  
                        private function onDateChangeHandler(event:Event):void  
                        {  
                              	if(startDF.text == "")  
                                {  
                                   startDF.selectedDate = start;  
                                }  
                                else  
                                {  
                                        start = startDF.selectedDate; 
                                        //endDF.selectedDate = start;             
                                }  
                                  
                                if(endDF.text == "")  
                                {  
                                        endDF.selectedDate = this.end;  
                                }  
                                else  
                                {  
                                        this.end = endDF.selectedDate; 
                                        dateRange["rangeEnd"] = this.end;
                                        startDF.selectableRange = dateRange;
                                }  
                                  
                        }                          
                          
                ]]>  
        </mx:Script>  
        <mx:ApplicationControlBar width="446" dock="true">  
                <mx:Label text="开始日期:" />  
                <mx:DateField id="startDF"  showToday="true" formatString="YYYY年MM月DD日"  
                        change="onDateChangeHandler(event)"/>  
                           
                <mx:Label text="结束日期:"/>  
                <mx:DateField id="endDF" showToday="true" formatString="YYYY年MM月DD日"  
                        selectableRange="{{rangeStart:start}}" change="onDateChangeHandler(event)"/>  
        </mx:ApplicationControlBar>  
           
</mx:Application>  

 

你可能感兴趣的:(xml,Flex,Adobe)