which was easy to follow. So I followed this tutorial then created a countdown for the London Marathon in flash. Below is the code I added in the Actions layer in Action Script:
this.onEnterFrame = function() {
var today:Date = new Date();
var currentYear = today.getFullYear();
var currentTime = today.getTime();
var targetDate:Date = new Date(currentYear,3,19);
var targetTime = targetDate.getTime();
var timeLeft = targetTime - currentTime;
var sec = Math.floor(timeLeft/1000);
var min = Math.floor(sec/60);
var hrs = Math.floor(min/60);
var days = Math.floor(hrs/24);
sec = string(sec % 60);
if (sec.length <>
sec = "0" + sec;
}
min = string(min % 60);
if (min.length <>
min = "0" + min;
}
hrs = string(hrs % 24);
if (hrs.length <>
hrs = "0" + hrs;
}
days = string(days);
var counter:String = days + ":" + hrs + ":" + min + ":" + sec;
time_txt.text = counter;
}
This is what the finished countdown timer I created looks like below. I added the Official London Marathon Logo and text countdown to the marathon apart from that everything else was done by following the tutorial.

No comments:
Post a Comment