Skip to main content
Known Participant
January 21, 2018
Answered

MOUSE_OVER in EventListener not detecting collision with mouse

  • January 21, 2018
  • 1 reply
  • 1509 views

stop();

blueTarget.addEventListener(MouseEvent.MOUSE_OVER, mousehandler2);

function mousehandler2(e:MouseEvent):void {

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();

}

Above is my coding. My issue is that whenever the mouse goes over blueTarget, it doesn't go to the lose screen as it's supposed to.

Am I missing something? Thanks

Luke

This topic has been closed for replies.
Correct answer JoãoCésar17023019

Would it be easier if I sent you my SWF of my project. and maybe FLA as well? Cause my code is inside if a button if that makes a difference.

Do you want my FLA & SWF File so you can see what I'm talking about?

Thanks

Luke


It makes a lot of difference. Because scope changes.

If your code is inside of the blueTarget, for example, than it should be:

addEventListener(MouseEvent.MOUSE_OVER, mousehandler2);

function mousehandler2(e:MouseEvent):void

{

    removeEventListener(MouseEvent.MOUSE_OVER, mousehandler2);

    MovieClip(root).gotoAndStop("lose");

}

1 reply

JoãoCésar17023019
Community Expert
Community Expert
January 21, 2018

The code is correct.

Make sure:

- You have a instance on stage called 'blueTarget';

- That it doesn't have any children getting in the way;

- Also that the 'blueTarget' doesn't have a irregular shape that it's interfering with the mouse over.

ChevyLukeAuthor
Known Participant
January 21, 2018

Hi JoaoCesar

My shape is a normal rectangle, I don't think children are in the way however I don't know how to check that and the shape on the stage is called blueTarget.

When the mouse goes over it, all it does is disappears and stays on that frame, doesn't go to lose screen which I named correctly

Thanks

Luke

JoãoCésar17023019
Community Expert
Community Expert
January 21, 2018

Oh I see...

You said you named your lose screen correctly. But the function gotoAndStop("lose") sends to a label on the timeline named "lose" not to a symbol on the stage called "lose".