clock.lzx
<library>
<resource name="clockbkgnd" src="images/lzclock_bkgrnd_final.swf"/>
<resource name="hourhand" src="images/lzclock_hourhand2.swf"/>
<resource name="minutehand" src="images/lzclock_minutehand2.swf"/>
<resource name="secondhand" src="images/lzclock_secondhand2.swf"/>
<resource name="secondhandshdw" src="images/lzclock_secondhandshdw.swf"/>
<resource name="glasshilite" src="images/lz_clock_hilite.swf"/>
<resource name="cap" src="images/lzclock_centercap.swf"/>
<font name="Kgr">
<face src="kroeger-6-plain-regular.ttf"/>
</font>
<class name="clock" resource="clockbkgnd">
<attribute name="stretches" value="both
"/>
<attribute name="width" value="${this.unstretchedwidth *.5}"/>
<attribute name="height" value="${this.width}"/>
<attribute name="act_height" value="${this.unstretchedheight}"/>
<attribute name="act_width" value="${this.unstretchedwidth}"/>
<attribute name="lasthour" value="0
"/>
<attribute name="lastminute" value="0
"/>
<attribute name="timezoneoffset" value="0
"/>
<text font="Helmet" fontsize="14" name="dayandampm" x="130" y="132" visible="false">SUN AM
<handler name="ontext">
this.setAttribute('x', 100 - Math.floor(this.getTextWidth()/2.0));
this.setAttribute('visible', true);
</handler>
</text>
<view name="hhs" resource="hourhand" x="${parent.act_width/2.0}" y="${parent.act_height/2.0}" width="0" height="0" opacity=".5" fgcolor="0x0"/>
<view name="hh" resource="hourhand" x="${parent.act_width/2.0 -3}" y="${parent.act_height/2.0 -3}"/>
<view name="mhs" resource="minutehand" x="${parent.act_width/2.0}" y="${parent.act_height/2.0}" width="0" height="0" opacity=".5" fgcolor="0x0"/>
<view name="mh" width="0" height="0" resource="minutehand" x="${parent.act_width/2.0 -3}" y="${parent.act_height/2.0 -3}"/>
<view name="shs" resource="secondhandshdw" x="${parent.act_width/2.0}" y="${parent.act_height/2.0}" width="0" height="0" opacity=".5"/>
<view name="sh" width="0" height="0" resource="secondhand" x="${parent.act_width/2.0 -3}" y="${parent.act_height/2.0 -3}"/>
<view resource="cap" x="${parent.act_width/2.0 -3}" y="${parent.act_height/2.0 -3}"/>
<view resource="glasshilite"/>
<method name="setCurrentTime">
// Get the current date and time local to this machine
var currentTimeObj = new Date();
// Tranlsate the time to the cities local time
currentTimeObj.setTime(currentTimeObj.getTime() + currentTimeObj.getTimezoneOffset()*60*1000); // UTC time
currentTimeObj.setTime(currentTimeObj.getTime() + + this.timezoneoffset*60*60*1000); // local to city
var hourNum = currentTimeObj.getHours();
// change time and get day
var dayNum = currentTimeObj.getDay();
var dayArray = ["Sun","Mon","Tue","Wed","Thur","Fri","Sat"];
// Get PM or AM
if (hourNum > 11) {
hourNum-=12; // for clock representation
var hourLabel="PM";
} else {
var hourLabel="AM";
}
this.dayandampm.setAttribute('text', dayArray[dayNum] + " " + hourLabel);
// Get Minutes and Seconds
var minNum=currentTimeObj.getMinutes();
var secNum=currentTimeObj.getSeconds();
// Move the hands of the clock...
var dur = 700;
if ( (this.lasthour != hourNum*30) || (this.lastminute != minNum*6) ){
this.lasthour = hourNum*30;
var hourPart = hourNum * 30 + ( minNum / 2 );
this.hh.animate('rotation',hourPart,dur);
this.hhs.animate('rotation',hourPart,dur);
}
if ( this.lastminute != minNum*6 ){
this.lastminute = minNum*6;
this.mh.animate('rotation',this.lastminute,dur);
this.mhs.animate('rotation',this.lastminute,dur);
}
this.shs.setAttribute('rotation',secNum*6,dur);
this.sh.setAttribute('rotation',secNum*6,dur);
</method>
<handler name="onsecond" reference="secondtimer">
this.setCurrentTime();
</handler>
<method name="setTimeZone" args="tzo">
this.timezoneoffset = tzo;
</method>
</class>
</library>
Cross References
Resources
Classes