Hit test in actionscript 3
In this Flash tutorial you will learn to use actionscript 3 to make a simple hit test, one of the most used functions and defenently needed if you want to make a flash game.
First off we will need to make two things, and object to move, in this case a ball, then the ground, so with the oval tool draw a ball, right click it and convert it to a movie clip, go to the properties panel and give it an instance name as shown below. I named mine ball.


Now with the rectangle tool make the ground and place it under our ball, right click and convert it to a movie clip, give it an instance name, I called mine ground.

Now the last thing we need so to hit F9 and type in our actionscript code, the lines with // infront of them is comments explaining the code, thats all the grey text, I have tried to explain it as simple as possible.
//Because this is AS3 everything needs to be called through
//eventlisteners, so this first lin calls and listens for the ball
ball.addEventListener(Event.ENTER_FRAME, enter_frame);
//here is our function, it is called at the beginning of the movie
function enter_frame(event:Event):void{
//An if statement, saying if the ball touches the ground,
//then just make a trace of text.
if (ball.hitTestObject(ground)) {
trace("ball is on the ground")
} else {
ball.y += 10
}
}
Now test your movie, if the ball hits the ground it should stop.