ActionScript Analog Clock - Page 2
Posted by : webzo on Mar 21, 2008
That's all; very simple, but accurate:

My clock on the left and the windows clock on the right.
Code Explanation
this.onEnterFrame = function()
{
var date = new Date();
A Date object has the current time and date of the computer its running.
We need to create one to get the time from it. var hours = date.getHours(); The function getHours() returns the current hour. var minutes = date.getMinutes(); getMinutes() returns the minutes. var seconds = date.getSeconds(); And getSeconds() returns the seconds. min._rotation = 360 / 60 * minutes; To get the angle needed just divide the number of minutes that exists (60') by 360 and multiply by the number of minutes we have now.
hour._rotation = 360 / 12 * hours;
sec._rotation = 360 / 60 * seconds;
}
The other two angles use the same logic. Note that the hours uses the 12-hour notation instead of the 24-hour notation.

no comment
Add comment