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

Chapter 5. Collision Detection > Detection Using hitTest()

Detection Using hitTest()

As you probably know, Flash's MovieClip object contains many methods and properties that assist in working with movie clips. When a movie clip is created, either in the authoring environment or with ActionScript, it inherits all the methods and properties of the MovieClip object. These methods and properties are then available to this new movie-clip instance.

We can use the hitTest() method of the MovieClip object to detect collisions in three simple scenarios. But before we discuss these three types of collisions, I'll introduce you to a new term, bounding box. Bounding box refers to the imaginary box that encloses everything in a movie clip. If you have a movie clip with a circle in it, then the bounding box for this movie clip is a square that is exactly big enough to fit the circle, with each side of the box touching the circle. Likewise, if you have an irregular shape or multiple shapes within a movie clip, then the bounding box will be made up of a rectangle that touches the uppermost piece in the movie clip, the leftmost piece in the movie clip, the rightmost piece in the movie clip, and the lowest piece in the movie clip.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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