1. Open your movie file and review the components. There is one moive
clip on the stage called hands. inside the clock movie clip are three
separate layers, one for each of the hands on the clock. Each movie clip
has an instance name, indicating the type of hand. We have secondhand_mc,
minutehand_mc, and hourhand_mc.
2. Click back to your main stage and click on the hands movie clip to
highlight it. We are going to put the hand movement scripts on this movie
clip as a clip event, using the event enterFrame. The enterFrame event
calls for the script to be played at the frame rate. The frame rate of
this movie is 12 frames per second, therefore on script in an onClipEvent(enterFrame){}
event handler would be played 12 times a second as long as the movie clip
it is attached to remains on stage.
Open
the actions panel with the hands movie clip highlighted. type in the framework
for the onClipEvent with the event of enterFrame. Type in onClipEvent(
and select the enterFrame from the drop down box. Finish the script by
closing the parentheses ) and add a set of curly brackets {}.
onClipEvent(enterFrame){
}
3. We will put in the actions to rotate each of the hands by a factor
equal to the previous rotation value plus a factor, determined be the
frame rate. Add the folloring lines to the event handler as action lines
for when the event occurs. Place them between the curly brackets (braces).
Click at the end of the open curly bracket(open brace). Hit your enter
key to go to the next line. Click the target button. Select the second
hand_mc and set the path to relative. Click ok.
Add
a period to the actionscript. A new drop down appears. select the property
_rotation.
Add the operator = . Type in the word Number (case sensitive). Open a
parenthesis and target the same movie clip. Add a period, and select _rotation
from the list. Close parenthesis and use the plus operator. Add 1/2. End
your script line with a semicolon.
4. Add scripts to change the rotation property of the minute hand and
the hour hand in the same way, changing the increment to 1/120 for the
minute hand, and 1/1440 for the hour hand.
The resulting script applied to your movie clip should look like this: