EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - About Controlling Movie Clips with Actionscript

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
352 Working with Movie Clips
For more information on movie clips, see the following topics:
About controlling movie clips with ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . .352
Calling multiple methods on a single movie clip . . . . . . . . . . . . . . . . . . . . . . . . . . . . .354
Loading and unloading SWF files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .355
Changing movie clip position and appearance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .357
Dragging movie clips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
Creating movie clips at runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
Adding parameters to dynamically created movie clips. . . . . . . . . . . . . . . . . . . . . . .364
Managing movie clip depths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .366
About caching and scrolling movie clips with ActionScript . . . . . . . . . . . . . . . . . . .369
Using movie clips as masks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .376
Handling movie clip events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .378
Assigning a class to a movie clip symbol. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .378
Initializing class properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .379
About controlling movie clips with
ActionScript
You can use global ActionScript functions or the methods of the MovieClip class to perform
tasks on movie clips. Some methods of the MovieClip class perform the same tasks as
functions of the same name; other MovieClip methods, such as
hitTest() and
swapDepths(), dont have corresponding function names.
The following example shows the difference between using a method and using a function.
Each statement duplicates the instance
my_mc, names the new clip new_mc, and places it at a
depth of 5.
my_mc.duplicateMovieClip("new_mc", 5);
duplicateMovieClip(my_mc, "new_mc", 5);
When a function and a method offer similar behaviors, you can select to control movie clips
by using either one. The choice depends on your preference and your familiarity with writing
scripts in ActionScript. Whether you use a function or a method, the target timeline must be
loaded in Flash Player when the function or method is called.
To use a method, activate it by using the target path of the instance name, a dot (.), and then
the method name and parameters, as shown in the following statements:
myMovieClip.play();
parentClip.childClip.gotoAndPlay(3);

Table of Contents

Related product manuals