0
votes

I'm trying to make a countdown timer, where I could easily set the endDate variable in html...

I can send strings to AS3 with flashvars="endDate=123", but how do I make it to be date (for example christmas)? - I need it to be date because then in AS3 I have something like endDate - todayDate = timeRemaining

2
Use ExternalInterface.Florent
See Here for more Information about the ExternalInterface. Basically it allows you to call javascript methods from as3, and as3 methods from javascript.user2655904

2 Answers

0
votes

Just pass date to flash vars using formats specified here and parse that string in AS3 using Date.parse() method.

In this example you get a countdown in days to Xmas.

var dateFromFlashVar : String = "2013/12/25 15:30:20 GMT+0300";
trace( new Date( new Date( Date.parse( dateFromFlashVar ) ).time - new Date().time ).getDate().toString() );
0
votes

to transfrom a unix_timestamp date to as3 Date, you can do:

// unixTimeStamp is in seconds so we multiply by 1000 because flash Date take miliseconds
var date:Date = new Date( unixTimeStamp*1000 );

to get back unix timestamp of a date you can do:

// divide by 1000 to get seconds instead of miliseconds
var timeStamp:int = date.time / 1000;

i hope this is what you where searching for