AS3 | Tips

Creating a date countdown timer in ActionScript 3 / Flash

Creating a countdown timer in ActionScript is quite easy. The essentials of it are:

  1. Specify a target date to countdown to using the Date class.
  2. Create a Timer instance to check the countdown time each second or so.
  3. At each tick of the timer calculate the number of milliseconds between now and the target date.
  4. Determine how many days, hours, minutes, seconds, etc. that number of milliseconds is equal to.
  5. Update the graphics to reflect the amount of time left.

The following is an example of a countdown timer, with a link to the source code below. This utilizes a reusable class file for the countdown timer. All code specific to this particular implementation can be found in com/anselmbradford/

This movie requires Flash Player 9

Download Source