adefesche
02-20-2009, 04:49 PM
Hey all,
I'm trying to create a clock that allows the user to select a time zone from a combobox and have the correct time show up on a clock in the next frame. Right now I have this actionscript for the combobox:
stop();
timeZone = myLocation.selectedItem;
myLocation.dataProvider = [
{label:"Select a City", data:0},
{label:"Dallas", data:6},
{label:"Los Angeles", data:8} ];
var oListener:Object = new Object();
oListener.change = function(oEvent:Object):Void{
trace(oEvent.target.value);
};
myLocation.addEventListener("change", oListener);
and the code on the clock frame looks like:
time=new Date(); // time object
seconds = time.getUTCSeconds()
minutes = time.getUTCMinutes()
hours = time.getUTCHours()
hours = hours +(minutes/60);
hours = hours -timeZone;
seconds = seconds*6; // calculating seconds
minutes = minutes*6; // calculating minutes
hours = hours*30; // calculating hours
sec._rotation=seconds; // giving rotation property
min._rotation=minutes; // giving rotation property
hour._rotation=hours; // giving rotation property
But for some reason the clock is not pulling the variable "timeZone" and always shows the hour hand at its default position (12). For example, the data for "Los Angeles" is 8. If I put "8" in the place of "timeZone" it works, but "timeZone" does not. Why??
I'm trying to create a clock that allows the user to select a time zone from a combobox and have the correct time show up on a clock in the next frame. Right now I have this actionscript for the combobox:
stop();
timeZone = myLocation.selectedItem;
myLocation.dataProvider = [
{label:"Select a City", data:0},
{label:"Dallas", data:6},
{label:"Los Angeles", data:8} ];
var oListener:Object = new Object();
oListener.change = function(oEvent:Object):Void{
trace(oEvent.target.value);
};
myLocation.addEventListener("change", oListener);
and the code on the clock frame looks like:
time=new Date(); // time object
seconds = time.getUTCSeconds()
minutes = time.getUTCMinutes()
hours = time.getUTCHours()
hours = hours +(minutes/60);
hours = hours -timeZone;
seconds = seconds*6; // calculating seconds
minutes = minutes*6; // calculating minutes
hours = hours*30; // calculating hours
sec._rotation=seconds; // giving rotation property
min._rotation=minutes; // giving rotation property
hour._rotation=hours; // giving rotation property
But for some reason the clock is not pulling the variable "timeZone" and always shows the hour hand at its default position (12). For example, the data for "Los Angeles" is 8. If I put "8" in the place of "timeZone" it works, but "timeZone" does not. Why??