Copy link to clipboard
Copied
I use this code from an YouTUBE tutorial:
addEventListener(Event.ENTER_FRAME, timehandler);
function timehandler(event:Event):void
{
var currentdate:Date = new Date();
second_hand.rotation = currentdate.seconds * 6
minute_hand.rotation = currentdate.minutes * 6 + currentdate.seconds / 10;
hour_hand.rotation = currentdate.hours * 30 + currentdate.minutes / 2;
}
And this clock work perfect, but how can I setup different Time Zone, not this one time zone on the computer?
currDate.time, not currDat.milliseconds.
Copy link to clipboard
Copied
you can use parameters in the Date constructor, but the Date class determines the current date from the users computer. so users in different time zones (and users with mis-set computer times/dates) will see something different than you.
Copy link to clipboard
Copied
Thank you, kglad! That idea is perfect for me, but can you explain me where exactly i should put this parameters?
Copy link to clipboard
Copied
eg, for the date 24hrs previous (prevDate) to the current date (currDate):
var currDate:Date=new Date();
var prevDate:Date=new Date(currDate.time-24*60*60*1000);
p.s. there's also a timezoneOffset Date property that might help you.
Copy link to clipboard
Copied
Thanks!
Now my code looks like this:
addEventListener(Event.ENTER_FRAME, timehandler);
function timehandler(event:Event):void
{
var currDate:Date=new Date();
var prevDate:Date=new Date(currDate.milliseconds-24*60*60*1000);
second_hand.rotation = currDate.seconds * 6
minute_hand.rotation = currDate.minutes * 6 + currDate.seconds / 10;
hour_hand.rotation = prevDate.hours * 30 + currDate.minutes / 2;
}
But there is couple of problems:
1. First of all, when our time is 20:00 h with "-24" the clock show 14:00h (2:00h)???
2. I setup the value to "-17" for instance, then the clock show 19:00h (7:00h) and after the time become one hour ahead to 21:00h the clock begins again from 19:00 (7:00).
I can show the defect here (have to wait a few seconds while load the campaign):
I'm so sorry about this, but I'm not working with Flash and actionscript and this is so unusual case for me!
Copy link to clipboard
Copied
currDate.time, not currDat.milliseconds.
Copy link to clipboard
Copied
Thank you!!! Now it works!
Copy link to clipboard
Copied
you're welcome.
(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)
Find more inspiration, events, and resources on the new Adobe Community
Explore Now