# hitTest not working

**URL:** <https://forum.kirupa.com/t/hittest-not-working/109539>\
**Category:** Uncategorized\
**Created:** [May 6, 2004, 2:24pm UTC](https://forum.kirupa.com/t/hittest-not-working/109539 "2004-05-06T14:24:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnsonn](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@johnsonn](https://forum.kirupa.com/u/johnsonn)\
**Post date:** [May 6, 2004, 2:24pm UTC](https://forum.kirupa.com/t/hittest-not-working/109539/1 "2004-05-06T14:24:49Z")

</div>

I have the following Movie and Frame scripts, can anyone see why my hit test is not working?

Movie Script:  
onClipEvent(load) {  
\_root.initGame();  
}

onClipEvent(enterFrame) {

```
_root.newPlane();
_root.movePlanes();
_root.movePlane();

// set the cursor
_root["cursor"]._x = _root._xmouse;
_root["cursor"]._y = _root._ymouse;

```

}

onClipEvent (mouseDown) {  
// show blast  
\_root[“cursor”].gotoAndPlay(“blast”);

```
// get the location of the click
x = _root._root["cursor"]._x;
y = _root._root["cursor"]._y;

// loop through all planes to see which was clicked
for (i=0; i&lt;10; i++) {

		// see if this was the one clicked
		if (_root["plane"+i].hitTest(x, y, false)) {

			// have the clip play the "hit" animation
			gotoAndPlay(2);

			// increase score and show it
			score++;
		
	}
}

```

}

Frame Script:  
function initGame() {  
// init plane variables  
nextPlaneTime = 0;  
nextPlane = 0;  
planes = [];  
numPlanes = 10;

}

function newPlane() {  
// more planes?  
if (nextPlane \< numPlanes) {

```
	// time for next?
	if (getTimer() &gt; nextPlaneTime) {

		
			// create new plane clip
			attachMovie("plane", "plane"+nextPlane, nextPlane);

			
				_root["plane"+nextPlane]._x = -30;
				

			// choose height of plane
			_root["plane"+nextPlane]._y = int(Math.Random()*100)+20;

			
			// add plane to array
			planes.push({clip: "plane"+nextPlane, d: dx});

			// set things up for next plane
			nextPlane++;
			nextPlaneTime = getTimer() + 2000;
		}
	}

```

}

function movePlanes() {  
// loop through planes in array  
for(i=planes.length-1;i\>=0;i–) {

```
	// get speed and clip
	dx = planes*.d;
	plane = _root[planes*.clip];

	// move plane AT SPEED OF 10
	plane._x += 10;

	

	// plane exit right
	} if ((dx &gt; 0) and (plane._x &gt; 570)) {
		plane.removeMovieClip();
		planes.splice(i,1);
	}
}

```

stop();
