I am trying to figure out how to load a date into an array and then retrieve
it in order to make calculations.
Here is the code:
var targetDate:Date = new Date(2008, 11, 25);
var dateArray = new Array();
var dateCount:Number=0;
_root.dateArray[0] = '2008, 11, 25';
_root.dateArray[1] = '2008, 11, 24';
_root.dateArray[2] = '2008, 11, 23';
trace(_root.targetDate);
function daysLeft(date){
var today:Date = new Date();
var currentTime = today.getTime();
var targetTime = date.getTime();
var timeLeft = targetTime - currentTime;
var sec = Math.floor(timeLeft/1000/60/60/24);
//trace(sec);
_root.days_txt.text = sec;
}
function rotatingDate(date){
trace(_root.dateArray[_root.dateCount]);
trace(_root.dateCount);
//trace(_root.dateArray.length);
if(_root.dateCount>= _root.dateArray.length) {
_root.dateCount=0;
_root.targetDate = new Date(_root.dateArray[_root.dateCount]);
trace(_root.targetDate);
_root.daysLeft(_root.targetDate);
_root.dateCount = _root.dateCount+1;
}else{
_root.targetDate = _root.dateArray[_root.dateCount];
trace(_root.targetDate);
_root.daysLeft(_root.targetDate);
_root.dateCount = _root.dateCount+1;
}
}
Thanks!