Add a month to selectable date range – Date Chooser – Actionscript 2

I have been working on a project where I need to select a date range starting today and ending a month from now, so the user cannot select anything in the past or over a month from now.

This is how I did it:

There is an instance of DateChooser on the stage with Instance Name “calDate”.

Select Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var todayDate:Date = new Date();
dateBeginDay = todayDate.getDate();
dateBeginMonth = todayDate.getMonth();
dateBeginYear = todayDate.getFullYear();

if ((todayDate.getMonth()+1)==12) {
	dateEndDay = todayDate.getDate();
	dateEndMonth = 1;
	dateEndYear = todayDate.getFullYear()+1;
} else {
	dateEndDay = todayDate.getDate();
	dateEndMonth = todayDate.getMonth()+1;
	dateEndYear = todayDate.getFullYear();
}
calDate.selectableRange = {rangeStart: new Date(dateBeginYear, dateBeginMonth, dateBeginDay), rangeEnd: new Date(dateEndYear, dateEndMonth, dateEndDay)}