Flex4 DateChooser控件之SCroll事件来设定年月
发布时间:2020-12-15 01:05:59 所属栏目:百科 来源:网络整理
导读:首先要设定当前年和月: //日历设置变量,当前日历控件中的年和月public var currentMonth:Number;public var currentYear:Number;..................................................................................this.currentYear=new Date().getFullY
首先要设定当前年和月: //日历设置变量,当前日历控件中的年和月 public var currentMonth:Number; public var currentYear:Number; ......................................... ......................................... this.currentYear=new Date().getFullYear(); this.currentMonth=new Date().getMonth()+1; //因为月份从0开始计数,所以要加上1。 trace("****:t"+currentMonth+"/"+currentYear+"******"); 然后在DateChooser控件中申明 <mx:DateChooser id="dateChooser" x="139" y="83" borderColor="green" scroll="changeMonth(event)" /> 然后在changeMonth(event)事件中实现其事件,细节如下所示: private function changeMonth(event:DateChooserEvent):void{ trace(event.detail); // mx.controls.Alert.show("hello world!!!"); //获取选中的月份 // mx.controls.Alert.show("当前的月份:t"+dateChooser.selectedDate.getMonth().toString()); //有四种情况 //nextMonth && previousMonth //nextYear && previousYear var currentValue:String = new String(event.detail); if(currentValue == "nextMonth"){ if(currentMonth >= 1 && currentMonth < 12) this.currentMonth += 1; else{ this.currentMonth = 1; currentYear+=1; } } else if(currentValue=="previousMonth"){ if(currentMonth > 1) this.currentMonth -= 1; else{ this.currentMonth = 12; currentYear -= 1; } } else if(currentValue == "nextYear"){ if(currentYear == 2100) return; currentYear += 1; } else if(currentValue=="previousYear"){ if(currentYear == 1900) return; currentYear -= 1; } //根据选中的年月来进行重新加载数据至DataGrid控件中 getAllCalenderService=new HTTPService(); getAllCalenderService.url="http://192.168.17.66:8080/Smarter/calendarSetting!getMonthSettings.action?year="+currentYear+"&month="+currentMonth; getAllCalenderService.method="post"; getAllCalenderService.addEventListener(ResultEvent.RESULT,getAllCalenderFunc); getAllCalenderService.send(); //重新向服务器后台取数据 } (完,待续...................................................................) ? 天道酬情,时不我待。 ? 岁月不待人。。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |