Date and Time

Get Adobe Flash playerWe will make a clock with hands. The registration point for the hand must be at the bottom with the hand pointing straight up. Then we can rotate the hands depending on the time.

You can add the old fashioned clock next to the digital clock or start a new project.

clockDraw the face of the clock by drawing a 12 pointed star. Use text to write each number, then with the magnet on, snap each number to a point, then delete the star and add a circle.

Draw one hand using a line and a triangle, or draw something more elaborate, and make it a movie clip called Hand. We will add three hands to the clock and name them hourHand, minuteHand and secondhand. Make sure that the registration for all three is in the center of the clock and all pointing straight up.


Write the code as show below:
In the movie above the time is displayed in a label lblTime:

this.addEventListener(Event.ENTER_FRAME,showTime);
function showTime(e:Event):void {
	var d:Date=new Date;
	hourHand.rotation=d.hours*30+d.minutes/2;
	minuteHand.rotation=d.minutes*6;
	secondHand.rotation=d.seconds*6;
}

Download the movie
You could also do this using a timer.

NEXT: That's All!