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<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() > 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 > 0) and (plane._x > 570)) {
plane.removeMovieClip();
planes.splice(i,1);
}
}
stop();