

To support the relief effort for China’s earthquake, the china-earthquake-relief.com needs a Flash timer to remind the time elapsed since the earthquake stroke at 14:28 May 12, 2008. So we made one.
It’s a Flash application developed right out of Adobe Flash CS3 Professional. It can be easily down with Flex but then the size of the swf could be much bigger than a pure Flash one.
There are not too much tricks once get the time calculation figured out, which is much harder than I thought. The main code is here:
stop(); countDownTxt.autoSize = true; var year = 2008; var month = 05; var day = 11; var hour = 23; var minute = 28; var date1 = new Date(year, month - 1, day, hour, minute); trace(date1) function countdown() { date2 = new Date(); //trace(date2) difSec = Math.floor((date2 - date1)/1000); sec = difSec % 60; difMin = Math.floor(difSec/60); min = difMin % 60; difHours = Math.floor(difMin/60); hours = difHours % 24; days = Math.floor(difHours/24); if (sec < 10) { sec = “0″ + sec; } if (min < 10) { min = “0″ + min; } if (hours < 10) { hours = “0″ + hours; } if(days < 0) { //trace(”the countdown is over”); gotoAndStop(2); } if(days < 10) { days = “00″ + days; } if(days < 100 && days >= 10) { days = “0″ + days; } countDownTxt.text = days + ” Days “ + hours + ” Hr “ + min + ” Min” + ” “ + sec + ” Sec”; } var intervalID = setInterval(countdown, 100); countdown();
Something to be noted:
So, go download the flashtimer.zip from here. It contains the swf and fla files. If you made improvements, drop me a copy please.
If you would like to make a comment, please fill out the form below.
Recent Comments