Using Flash AS3 to call methods of The MovieClip Class

Working with Fuctions and Methods | Using AS3 to call methods of The MovieClip Class
1. Begin a new Flash file
2. Rename Layer 1 to Circle.
3. Draw a circle that is roughly 50×50 pixels at the top-left corner of the stage using the Oval tool from the Tool palette.
4. Select the circle and convert it to a MovieClip symbol named mcCircle (Figure 3.1).

( Figure 3.1: Convert the circle shape to a MovieClip named mcCircle )
5. Select the mcCircle symbol on the stage and give it an instance name of mcCircle in the Properties panel (Figure 3.2).

(Figure 3.2 : Assign the circle an instance name of Circle )
6. Double-click mcCircle on the stage to enter its timeline.
7. Select the circle shape and convert it to a Graphic symbol called Circle.
8. Insert a new keyframe at frame 10 and drag the circle graphic instance to the right
side of the stage.
9. Insert a keyframe at frame 20 and drag the Circle graphic instance back to the left side of the stage
(x 0 , y 0).
10. Select the keyframe at frame 1 and select Motion from the Tween type drop-down menu in Properties panel (Figure 3.3). Repeat this step for frame 10.

(Figure 3.3 : Select the Motion tween type for the keyframe to tween the circle from frame 1 to frame 19 abd frin frane 19 to frame 20.)
11.Preview your movie; you should see the Circle moving back and forth across the stage.
12. To stop the timeline of mcCircle on the first frame, add a new layer named Actions. Select the first keyframe on the Actions layer and open the Actions panel (by choosing Window > Actions).
13. Add the following stop() method to stop the timeline of mcCircle at frame1: stop();
14. Return to the main timeline by clicking Scene 1 at the top left of the stage.
15.Create a new layer named Actions on the main timeline. Select the first keyframe on the Action layer and open the Actions panel.
16.Call the instance name mcCircle followed by its gotoAndPlay(0) method to tell the timeline of mcCircle to play frame frame 2:
mcCircle.gotoAndPlay(2);
17. Preview you movie. You should see mcCircle begin to play from frame 2 and the stop once it returns to frame 1 in its timeline, where it had been commanded to stop again by the stop() method.18. Call the gotoAndStop() method to tell mcCircle to go to and stop at a particular frame. The following code tells mcCircle to go to and stop at frame number 10:
mcCricle.gotoAndPlay(10);
19. Preview you movie. You should see the Circle stopped at the right side of the stage.
Tips
In Flash, when a timeline animation reaches its last frame, the playhead will return to frame 1 and continue looping unless Action Script tells it otherwise.
We will continue to work with methods of different class as we move throught this book. Althought there are all softs of different methonds, the dot syntas we just used to call methods of the MovieClip class is the same for calling all methods of all objects of classes.
Related posts:
Click here to Advertise Here





















