This is a simple hit test which I have attached to a basket ball back board in a shooting game.
onClipEvent (enterFrame) {
flag = this.hitTest(_root.ball);
if (flag == true) {
_root.ball.xVelocity = -2*_root.ball.xVelocity;
}
}
The on clip event enter frame sets it up as a loop. In this format it must be tagged to a M/C for it to work. In fact if you try to put it on anything but a Movie clip it simply will not paste into your action script panel.
So it loops and every time it does it checks to see if “this”, meaning the movie clip that this is attached to, is touching another movie clip named ball, on the main time line.
the stuff inside the {}'s is what the a/s should do if a hit is detected.
So a basic hit test looks like this
flag = myMovieClip.hitTest(myOtherMovieClip);
if (flag == true) {
}