Controlling Movie Clips

In Chapter 13, 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 ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.