Clock

Code Actionscript 2.0

Frame action

onEnterFrame = function () {
now = new Date();
h = now.getHours();
m = now.getMinutes();
s = now.getSeconds();
handh._rotation = h * (360 / 12);
handm._rotation = m * (360 / 60);
hands._rotation = s * (360 / 60);
};

Code Actionscript 3.0

addEventListener(Event.ENTER_FRAME, enterFrame); function enterFrame(e:Event) { var datum = new Date(); var h = datum.getHours(); var m = datum.getMinutes(); var s = datum.getSeconds(); handh.rotation = h * (360 / 12); handm.rotation = m * (360 / 60); hands.rotation = s * (360 / 60); }

Description

In this example, an analog clock demonstrates data visualization. In contrast to a digital clock, the hours, minutes and seconds are directly transformed into perceivable properties (rotation). With this script, the current values of hour, minute and second are used to set the rotation of the clock hands to the appropriate angles.

Download

Right click: Flashfile AS 2.0 | Flashfile AS 3.0 | SWF-File


Share