Skip to main content
Participant
October 11, 2011
Question

Mouse Move fires Mouse Click

  • October 11, 2011
  • 1 reply
  • 451 views

I am trying to have two guestures on the stage which I thought should be pretty simple implemented: 

Mouse_Move for sweep Gestures and mouse click to enable..

So I have 2 Eventlisteners on my stage:

stage.addEventListener(MouseEvent.CLICK, taphandler);

stage.addEventListener(MouseEvent.MOUSE_DOWN, mousedownhandler);

The main problem is that every type of sweeping on the screen also fires the taphandler()..

Any ideas on how to identify the correct event?

I tried to to my taphandler only if(!event.buttondown) but no success.

This topic has been closed for replies.

1 reply

Colin Holgate
Inspiring
October 11, 2011

You can work around your problem by counting the number of mouse move events. Then, in the Click function you look to see if the number of mouse moves was more than zero, and if it was, don't do the click action.

It could be that even a brief press will generate some mouse move events, so you could make your test be to see if there were more than 5 mouse moves. It would something like this:

var movecounter:int = 0;

function mousedown(e:MouseEvent){

movecounter = 0

}

function mousemove(e:MouseEvent){

movecounter++

}

function mouseclick(e:MouseEvent){

if(movecounter>5) return;

//do your click actions

October 13, 2011

>>The main problem is that every type of sweeping on the screen also fires the taphandler()..

How many tap handler events are fired in this case. If it's one then its expected.

To better use gestures, you can try out MultiTouch functionality (in place of mouse clicks), link for the same is here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/ui/Multitouch.html