start page | rating of books | rating of authors | reviews | copyrights

Book HomeActionScript: The Definitive GuideSearch this book

C.2. Controlling Movie Clips

In Chapter 13, "Movie Clips", we learned how to control clips using Flash 5 techniques. Here we consider the equivalent Flash 4 techniques.

Prior to Flash 5, we would execute special Movie Clip Actions to control a movie clip. We would say "Tell the clip named eyes to play," using the following:

Begin Tell Target ("eyes")
	Play
End Tell Target

But as of Flash 5, movie clips can be controlled more directly, through built-in methods. For example:

eyes.play( );

Similarly, to access the built-in properties of a movie clip prior to Flash 5, we would use explicit property-getting and property-setting commands, such as:

GetProperty ("ball", _width)
Set Property ("ball", X Scale) = 90

As of Flash 5, we can retrieve and set a movie clip's properties using the dot operator, just as we would access the properties of any object:

ball._width;
ball._xscale = 90;

Prior to Flash 5, to access variables inside a movie clip, we used a colon to separate the clip name from the variable name:

Set Variable: "x" = myClip:myVariable

As of Flash 5, a variable in a movie clip is simply a property of that clip object, so we now use the dot operator to set and retrieve variable values:

myClip.myVariable = 14;
x = myClip.myVariable;

Finally, prior to Flash 5, we would access nested levels of movie clips using a directory-tree metaphor of slashes and dots:

clipA/clipB/clipC
../../../clipC

Because movie clips are object-like data as of Flash 5, we can store one clip as a property of another clip. We, therefore, use the dot operator to access so-called nested clips, and we use a clip's reserved _ parent property to refer to the clip that contains it:

clipA.clipB.clipC;
_parent._parent._parent.clipC;


Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.