# HitTest: Getting the BALL in the HOOP

**URL:** https://forum.kirupa.com/t/hittest-getting-the-ball-in-the-hoop/114110
**Category:** Uncategorized
**Created:** [June 24, 2004, 8:22pm UTC](https://forum.kirupa.com/t/hittest-getting-the-ball-in-the-hoop/114110 "2004-06-24T20:22:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![akawoody](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@akawoody](https://forum.kirupa.com/u/akawoody)
#### Post date: [June 24, 2004, 8:22pm UTC](https://forum.kirupa.com/t/hittest-getting-the-ball-in-the-hoop/114110/1 "2004-06-24T20:22:47Z")

</div>

[font=Arial]I am trying to create a very simple “drag-and-drop move to the next frame” movie. I have searched the forums and tried a number of things, but to no avail.

I have a three frame movie. The first two frames loop with a movie clip of a BALL and a movie clip of a HOOP. Frame 2 has an action of gotoAndPlay(1); to create the loop. When the user “grabs” the BALL via this hitTest, I want the movie to advance to Frame 3 when BALL goes into the HOOP.

The BALL is on its own layer with the following code:

onClipEvent (load) {  
\_x = 78;  
\_y = 163;  
speed = 1;  
}  
onClipEvent (enterFrame) {  
if (hitTest (\_root.\_xmouse, \_root.\_ymouse, true)) {  
endX = \_root.\_xmouse;  
endY = \_root.\_ymouse;  
\_x += (endX - \_x) / speed;  
\_y += (endY - \_y) / speed;  
}  
}

The HOOP movie is on its own layer with the following code:

onClipEvent (enterFrame) {  
if (\_root.hitTest(\_root.ball)) {  
\_root.gotoAndPlay(3);  
}  
}

This doesn’t work at all. When the HOOP code is in movie, the BALL script doesn’t work. When I remove the HOOP script, the BALL moves around as it should.

I’ve tried putting the movies on the same layer–no good. Adding a stop(); command in place of the loop–no good. Switching layer order–no good.

Any help or alternatives would be appreciated.

Woody[/font]
