首先要设定当前年和月:
//日历设置变量,当前日历控件中的年和月 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(); //重新向服务器后台取数据 }
(完,待续...................................................................)
天道酬情,时不我待。
岁月不待人。。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。