• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 7. Controlling the Movie Clip > Duplicating and Removing Movie Clips

Duplicating and Removing Movie Clips

Creating multiple instances from existing movie clips on the fly is possible with the action duplicateMovieClip. Duplicate movie-clip instances are given their own unique names as well as a specific depth level for each instance, which determines stacking order, just as it does with the movie-clip property swapDepths. Once a movie clip is duplicated, you can control any of its properties, navigate within its Timeline, and use it like any other movie clip. Duplicating movie clips can come in handy to dynamically generate graphics. For example, by duplicating short line segments or simple primitive shapes and then controlling their properties (position, scale, rotation), you can create animations or even simulate 3D objects on the fly. (That requires a lot of math, though!) Or, if you want an infinite supply of a certain draggable item such as merchandise pulled off the shelf of an online store, you can duplicate it each time as the viewer drags it away from its original spot. In a game of Asteroids, for example, creating the breakup of a big asteroid into smaller asteroids would be made easier by duplicating the asteroid movie clip.

It's a common practice to duplicate movie clips by using looping functions that append successive numbers to the instance name and automatically assign depth levels. For example, a movie clip named asteroid may be duplicated in this manner, producing asteroid1 in Depth Level 1, asteroid2 in Depth Level 2, asteroid3 in Depth Level 3, and so on. Check out Chapter 9, Controlling Information Flow, to learn about the looping actions that complement the duplication of movie clips.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint