MouseEvent.CLICK not responding on stage

4.2k views Asked by At

When I listen to mouse click event on the stage, it seems it's not always responding to my mouse click event. what I have is:

stage.addEventListener(MouseEvent.CLICK, Test);

function Test(event:MouseEvent):void
{
    trace("test");
}

I usually have to click a few times randomly on the stage to get the trace statement. I thought when I add this event listener to the stage, it should respond to any mouse click within the swf area, no? Any ideas?

Thanks.

2

There are 2 answers

2
sean On

Are you working with Flex? If so, try the following instead:

mx.core.Application.application.addEventListener(MouseEvent.CLICK, Test);

In Flex adding the listener to stage doesn't seem to work... no idea why.

0
kroe On

try a more "loosy" event

MouseEvent.MOUSE_DOWN

if you want to trigger your event only when user releases the button, try

MouseEvent.MOUSE_UP