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

Chapter 11. Manipulating Information > Keeping Track of Movie Clips with Arrays

Keeping Track of Movie Clips with Arrays

Sometimes, you’ll have to deal with many movie clips on the Stage at the same time. Keeping track of them all and performing actions to modify, test, or evaluate each one can be a nightmare unless you use arrays to help manage them all. Imagine that you are creating a game in which your viewer has to avoid falling rocks from the sky. You can use the hitTest() method to see whether each falling-rock movie clip intersects with the viewer. But if there are 10 rocks on the Stage, that potentially means 10 separate hitTest() statements. You can better manage the multiple falling rocks by putting them in an array. Doing so allows you to perform the hitTest() on one array instead of on many separate movie clips.

Put a movie clip into an array by referencing its name with array access operators, like so:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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