Flash countdown tutorial
Download source files: as3 timedate contdown
Step 1
- Create New Flash File ActionScript 3.0
- Select the Selection Tool V
- Go to Properties tab and press Edit button and set the width of your document to 440 pixels and the height to 175 pixels, set frame rate to 12 fps and select any color you want as background.
- Change the layer name to clock text fields ( double click on it ).
- Add another layer and double click on it to change his name to AS3
Step 2
- Go to the clock text fields layer
- Using the text tool (T), make 3 text columns for the output.
- The first column will have the Instance name : now_txt ( present date)
- Second column will have Instance name : newyear_txt (new year date )
- Last column the biggest column will have : timeString ( time left )
Step 3
- Final step , we will move to AS3 layer.
- Select first frame and hit F9 to open AS3 panel and copy/paste the following code:
//Create a date object for newyear Morning
var newyear:Date = new Date(2010, 11, 31, 0, 0, 0, 0);
//Current date object
var now:Date = new Date();
// Conditional to snap to frame 3 if it is xmas or past New Year
if (now >= newyear) {
gotoAndStop(3);
}
// Set the difference between the two date and times in milliseconds
var timeDiff:Number = newyear.getTime() – now.getTime();
//Convert the timeDiff(which is in milliseconds) into regular seconds-minutes-hours-days
//The Math.floor is the closest rounded integer that is less than or equal to the decimal number
var seconds:Number = Math.floor(timeDiff / 1000);
var minutes:Number = Math.floor(seconds / 60);
var hours:Number = Math.floor(minutes / 60);
var days:Number = Math.floor(hours / 24);
// Set the remainder of the division vars above
hours %= 24;
minutes %= 60;
seconds %= 60;
// String all vars together for display
var timeRemaining:String = “Days= ” + days + “ Hours= ” + hours + “ Minutes= ” + minutes + “ Seconds= ” + seconds;
// Display everything in their dynamic text fileds
timeString.text = timeRemaining;
now_txt.text = “Now = ” + now;
newyear_txt.text = “New Year = ” + newyear;
- Select Frame 2 press F9 and copy/paste the following code:
gotoAndPlay(1);
- Select Frame 3 press F9 and copy/paste the following code:
stop();





June 14, 2010 at 2:42 am
Wow this is a great resource.. I’m enjoying it.. good article
March 17, 2011 at 12:02 pm
Simply Great, user-friendly and well customizable. I’m grateful.
June 3, 2011 at 6:35 pm
While this subject can be very touchy for most people, my opinion is that there has to be a middle or common ground that we all can find. I do appreciate that youve added relevant and intelligent commentary here though. Thank you!