hi. i’ve got a ‘for’ loop which creates a calendar. it works good. now i want it to recognize the current day and highlight it. here’s the code. the problem area is the very last if/else statement at the bottom.
the variables:
// Set the Initial Values for the Date Objects
now = new Date();
today = now.getDate();
month = now.getMonth();
year = now.getFullYear();
// First Date of Month
firstDate = new Date (year, month, 1);
firstDay = firstDate.getDay();
// Last Day of Month
lastDate = new Date(year, month+1, 0);
lastDay = lastDate.getDate();
the layout:
for(var j:Number=1; j <= lastDay; j++){
// Create the Empty Movie Clip
_root.createEmptyMovieClip("dateClip"+j,300+j);
var dateClip:MovieClip = _root["dateClip"+j];
// Create a Text Field Inside them
dateClip.createTextField("thisDate"+j,j,0,0,indColWidth,colHeight);
// Set Text Field Properties
dateClip["thisDate"+j].selectable = false;
dateClip["thisDate"+j].border = true;
dateClip["thisDate"+j].text = j;
// Define the Formatting
var format:TextFormat = new TextFormat();
format.align = "center";
dateClip["thisDate"+j].setTextFormat(format);
// Position the Clips
dateClip["thisDate"+j]._x = indColWidth * firstDay;
dateClip["thisDate"+j]._y = startThiRowYPos;
firstDay++;
// If it's Saturday, Increment the Week Count
if (firstDay == 7) {
firstDay = 0;
startThiRowYPos += 25;
}
// If it's today, give the text field a background fill
if(today && month && year){
// give it a background fill
dateClip["thisDate"+today].border = true;
dateClip["thisDate"+today].background = true;
dateClip["thisDate"+today].backgroundColor = 0xCCCCCC;
}
the area right above here is the problem area.
i figured part of it out. now i can get the date to have a background but, for example, today’s the 21st and now the 21st of every month is highlighted.
any help is always appreciated.
thanks. - fumeng.