stan4d
asked on
How can I set actionscript 3 timer to read time from server, GMT or UTC rather than local machine?
I am creating a timer to countdown to New Years at Times Square. I found this great tutorial to create a timer but it reads time form the end user's computer so if they are in a different time zone it will give the wrong time.
http://schoolofflash.com/2008/04/tutorial-creating-a-timer-in-actionscript-3/
Is there a way to tell Flash to read from the server's clock or GMT or UTC and then adjust?
http://schoolofflash.com/2008/04/tutorial-creating-a-timer-in-actionscript-3/
Is there a way to tell Flash to read from the server's clock or GMT or UTC and then adjust?
btw... I am using Actionscript 3.0
if you need AS 2.0 then instead of using the LoaderInfo class, you can just reference the passed in variable like this...
_root.endyear, _root.endmonth, _root.endday
so you can use this...
var endDate:Date = new Date( _root.endyear, _root.endmonth, _root.endday );
rp / ZA
if you need AS 2.0 then instead of using the LoaderInfo class, you can just reference the passed in variable like this...
_root.endyear, _root.endmonth, _root.endday
so you can use this...
var endDate:Date = new Date( _root.endyear, _root.endmonth, _root.endday );
rp / ZA
ASKER
Thanks for the quick reply.
That works to control the end date, but what I'm looking to do is control the timezone that the countdown is relative to. Right now it is getting the time from my computer regardless of what time zone I view it. If I'm not set to New York time on my computer then my countdown is wrong.
In this example I'm focused on 12:00 New York time. So no matter where you view it from I need to show the New York countdown. So the timer will actually reach 00:00 at 12:00am in New York, 9:00pm in California, 6:00pm in Hawaii, etc...
BTW - need for AS3 - thanks.
That works to control the end date, but what I'm looking to do is control the timezone that the countdown is relative to. Right now it is getting the time from my computer regardless of what time zone I view it. If I'm not set to New York time on my computer then my countdown is wrong.
In this example I'm focused on 12:00 New York time. So no matter where you view it from I need to show the New York countdown. So the timer will actually reach 00:00 at 12:00am in New York, 9:00pm in California, 6:00pm in Hawaii, etc...
BTW - need for AS3 - thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry - I've been trying to make it work for a while - no success. Is it possible you could please provide a sample showing implenmented getUTCHours? There's got to be something I'm missing. Many thx.
ASKER
Got it working - thanks for your help!
here is what i put in my first frame...
// LoaderInfo example code
var loaderObj:Object = LoaderInfo(this.root.loade
var theYear:int;
var theMonth:int;
var theDay:int;
if ( loaderObj.endyear )
{
theYear = loaderObj.endyear;
theMonth = loaderObj.endmonth;
theDay = loaderObj.endday;
}
else
{
// does not exist, so set manually
theYear = 2010;
theMonth = 0;
theDay = 1;
}
var endDate:Date = new Date( theYear, theMonth, theDay );
then you just need to pass in the three variables... endyear, endmonth, endday
rp / ZA