PHP Countdown for 2001/2002/2003-2099

Mittwoch, 26. Dezember 2001 by shck

(Click here for FULLSCREEN)


This tutorial will teach you how to make a countdown with realtime data from server.

Mostly the Server-Time is as good as the Atomic-Server-Time. It's easy to use it with php in flash as variable.

My ActionScript is able to create a countdown from now to the end of the current year and this automaticly every year until 2099 (I tested it).

All you need is a PHP-Server and Flash 5 (or higher) and a little bit knowledge about ActionScript.

You can visit my page to see this tutorial work:

First we create a new movie with 4 frames and 2 layers (Actions and Ebene 1).

In the first frame we write this ActionScript:

// Copyright
loadVariablesNum ("shckcount.php?r="+random(9999), 0);

shcknjahr = Number(shckjahr)+Number(1);
shckaday = Number(364);
if (Number(shckjahr)/4 == int(Number(shckjahr)/4)) {
    shckaday = Number(365);
shcktarget = ((shckaday-Number(1))*24*60*60)+(23*60*60)+(59*60)+60;
shcknow = ((shckyday-Number(1))*24*60*60)+(shckstun*60*60)+(shckmin*60)+Number(shcksek);
shckcount = Number(shcktarget)-Number(shcknow)+Number(1);
x = shcksek;
if (x>0) {
    gotoAndPlay (3);

shckcount.php is the php-file in the same directory which includes all variables.

x = shcksek;
if (x>0) {

This 'if' is for the loaded variables, if shcksek = 0 (variables from php are not downloaded) goto next frame.

2. Frame

gotoAndPlay (1);

3. Frame

shckhead = "COUNTDOWN "+shcknjahr;
shckcount = Number(shckcount)-Number(1);
if (shckcount==number(-1)) {
    gotoAndPlay (1);

shckhead, shckcount are the variables for the dyn. text field in Layer 1 (Ebene 1). With shckcount = Number(shckcount)-Number(1) we need not a further request of the server time because we create with this function our own seconds-time.

Attention: we have to put the film-sequenze to 1 BpS!

The 'if-action' is for the condition of countdown <0, then we goto frame 1 and load the server data again because we have a new year variable!

In Layer 1 we create 3 text fields.

"COUNTDOWN 2002" is a dynamic text field with variable "shckhead".

"(IN SECONDS)" is a stat. text field.

"31449600" is also a dyn. text field with variable "shckcount".

4. Frame

gotoAndPlay (3);

Finally we create the php-file with a simple texteditor and name it 'shckcount.php' with follow content:

$shckzeit = time(); 
$shckdat = getdate();
$shckjahr = $shckdat[year];
$shckyday = $shckdat[yday];

$shckstun = $shckdat[hours];
$shckmin = $shckdat[minutes];
$shcksek = $shckdat[seconds];

print "&shckjahr= $shckjahr&";
print "&shckyday= $shckyday&";
print "&shckstun= $shckstun&";
print "&shckmin= $shckmin&";
print "&shcksek= $shcksek&";

You can test your file on the php-server:

Then you can test the flash-file (FULLSCREEN):

That is it.

For questions visit my forum, for greetings please go to my guestbook!