actionscript-3flashflash-cs4

HitTestPoint not working, collisions not happening


I'm trying to create something similar to Impossible Quiz Question 5 (1st quiz). However the hitTestPoint appears to be not reading. I'm not exactly sure where my error is.

Here is my full line of code.

stop();

blueTarget.addEventListener(MouseEvent.MOUSE_OVER, mousehandler2);
function mousehandler2(e:MouseEvent):void {
    if (blueTarget.hitTestPoint(mouseX,mouseY,true)) {
        removeEventListener(MouseEvent.MOUSE_OVER, mousehandler2);
        gotoAndStop("lose");
    }
}
nexttButton.addEventListener(MouseEvent.MOUSE_DOWN, mousehandler3);
function mousehandler3(e:MouseEvent):void {
    removeEventListener(MouseEvent.MOUSE_DOWN, mousehandler3);
    MovieClip(root).nextFrame();
}

Thanks for the help!


Solution

  • Do you want the player to lose if he passes the mouse over the blueTarget? If so, you can remove your if statement because the mouse over event is already added to the blueTarget