Countdown Timer - Set date with PHP script

Hello, I did some site searches but didn’t see any posts on this, but did find an excellent princess bride quote thread. I also have been looking at many walkthroughs on inserting php into flash actionscript, but can’t seem to get what I want working.
This countdown from: http://www.kirupa.com/developer/mx/countdown.htm
is great, and will fit our needs.


// define the event date counting down to
// this is constant so it won't need to be
// calculated in the onEnterFrame function below
// currently counting down 'til christmas of 2003
// Date( year, month-1, date [, hour [, minute [, second [, millisecond]]]])
eventDate = new Date(2003, 11, 25);

I replaced 2003, 11, 25 with server.year server.month server.day

In the gettime.php I added:

<?php
echo "time=" . time();
$year = "2007";
$month = "11";
$day = "4";
$hour = "05";
$minute = "21";

print("&year=$year");
print("&month=$month");
print("&day=$day");
print("&hour=$hour");
print("&minute=$minute");
?>

I will replace the values with a value from a form post in a different page, but want to see if the values from php will go to the swf.

It just creates a blank swf. I really like the countdown timer as is, but just want an input page for others to be able to submit a new time to count down to.

Thanks for any input.

I removed the code from settime.php, and made spawntime.php:


<?php
$year = "2006";
$month = "2";
$day = "22";
$hour = "16";
$minute = "00";

$time = "" ;
$time .= "year=" . $year . "&" ;
$time .= "month=" . $month . "&" ;
$time .= "day=" . $day . "&" ;
$time .= "hour=" . $hour . "&" ;
$time .= "minute=" . $minute ;

echo $time ;
?>

It produces:

year=2006&month=2&day=22&hour=16&minute=00
in the servercountdown.fla near the bottom, I loaded the vars from spawntime.php

server.load("gettime.php");
/* gettime.php:

<?php
echo "time=" . time();
?>

*/
spawn = new LoadVars();
spawn.load("spawntime.php");
// now, since the counter clip has to wait for the time to be loaded, 
// its a good idea not to show it act all wierd as it has nothing to control
// how it plays its numbers.  We'll just hide it until the onLoad
counter._visible = false;

The movie works fine, but when I replace the
eventDate = new Date(2006, 2, 23, 12, 00)
with
eventDate = new Date(spawn.year, spawn.month, spawn.day, spawn.hour, spawn.minute);
The movie will go for 1 second countdown. It has to be some easy syntax, but do not see how this is different than the 15 or so threads searched on this forum.
I don’t know exactly how to get the variables listed.
Exporting movie as Flash 8, Actionscript 2.0

FYI: got response at macromedia for anyone else wanting to do such to his countdown timer:

The problem in your code is that date constructor needs three parameters Year, Month and date where as you are passing only one parameter. Though you have commans in your variable, they are part of the string and hence considered as part of the string. So, break them apart in to 3 and then pass them to date constructor as three params. Here is a code for that

 // Assume PHP returned the string "2006, 2, 25
var date_dt:Date;
var day_num:Number;
var month_num:Number;
var year_num:Number;
var this_mc = this;
spawn = new LoadVars();
spawn.onLoad = function (success:Boolean) {
     if (success) {
          var dateSplit_array:Array = new Array();
          dateSplit_array = this.time.split(",");
          this_mc.year_num = Number(dateSplit_array[0]);
          this_mc.month_num = Number(dateSplit_array[1]);
          this_mc.day_num = Number(dateSplit_array[2]);
          this_mc.date_dt = new Date(this_mc.year_num, this_mc.month_num, day_num);
     } else {
          trace("Error connecting Server");
     }
}
spawn.load("http://url/spawntime.php"); // Always define onLoad event function before calling load