Actionscript Analog Clock

Category : Flash Views : 6260
Version : 8 Rating
3.5/5 (23 votes)
Type : Text Source File: actionscript-analog-clock.zip
Result: See the result


Previous | 1 | 2 | Next

Very simple design, but the clock is exactly synced with the system time.
Free Flash Tutorials, Actionscript, Analog Clock

The first thing to do is the hand Movie Clips, you need to make three of them: "HandHour", "HandMinute" and "HandSecond".
Free Flash Tutorials, Actionscript, Analog Clock

They need to be different in size, color and thickness. And the registration point should be located as in the image above.

Create another Movie Clip named "Clock", inside draw a clock without the hands; then start placing the hands: seconds, minutes, hours.

And give them the instance names: "sec", "min", "hours".

Select the hands Movie Clips, click on the Filters tab and add a "Drop Shadow" filter with these settings:
Free Flash Tutorials, Actionscript, Analog Clock

Now on the first frame of this Movie Clip paste:
this.onEnterFrame = function() { //new Date object; with day and time var date = new Date(); //get hour with the date object var hours = date.getHours(); //get minutes var minutes = date.getMinutes(); //get seconds var seconds = date.getSeconds(); //360 degrees divided by 60 minutes equal the degrees for each minute. //Multiply the degrees by minute with our "minutes" //variable to get the angle. min._rotation = 360 / 60 * minutes; //360 degrees divided by 12 hours times "hours" variable hour._rotation = 360 / 12 * hours; //360 degrees divided by 60 seconds times "seconds" variable sec._rotation = 360 / 60 * seconds; }


del.icio.us digg it Reddit Stumble Upon Technorati

Previous | 1 | 2 | Next




Supporters

Reseller Web Hosting