A while back I posted a demo of shape-based hit detection in Flash 8. At the time, I wasn’t allowed to post the source code, but promised I would later. So here it is.
The com.gskinner.sprites.CollisionDetection class is really simple to work with, there is a single static method called checkForCollision with four parameters:
movieClip1, movieClip2 – The MovieClip instances to check for collision.
alphaTolerance – a number from 0 to 255 that specifies the transparency tolerance when testing the collision. A higher number will increase the tolerance (ie. allow more transparent parts of the MovieClip to register collisions). Defaults to 255.
Returns a Rectangle object specifying the intersection of the two MovieClips in the _root coordinate space, or null if they do not intersect.
Check out the original post for more information on how the class works.
Click here to download. It includes two simple demos to help you get started with it.