DekGenius.com
[ Team LiB ] Previous Section Next Section

Recipe 7.1 Referring to Movie Clips via ActionScript

7.1.1 Problem

You need to refer to a movie clip programmatically.

7.1.2 Solution

If you are creating the movie clip at authoring time, select the movie clip on stage and specify an instance name for it using the Property inspector. Then you can refer to it by that name via ActionScript.

7.1.3 Discussion

We saw in the Introduction how to refer to movie clips throughout your ActionScript code. But what names should you substitute for myMovieClip or myNestedMovieClip in the earlier examples to refer to your own movie clips?

The instance name you use in your code must match the name of the movie clip instance on stage, not the name of the Library symbol from which the clip is derived. Therefore, you must set the clip's instance name using the Property inspector before you can refer to it from ActionScript (see Figure 1-4). For example, if you've set the instance name of a movie clip to "circle_mc" using the Property inspector, you can control it via ActionScript:

circle_mc._xscale = 200;

7.1.4 See Also

For information on working with runtime-generated movie clips, see Recipe 7.2, Recipe 7.18, and Recipe 7.19. Also refer to Recipe 3.1.

    [ Team LiB ] Previous Section Next Section