Skip to main content
Participant
October 5, 2011
Question

Swipe vs. Touch Event

  • October 5, 2011
  • 1 reply
  • 1067 views

Hi all,

After developping some tests with AIR for Android, this question came to me : how can I set priority to a swipe event vs a touch event.

My application is composed of:

  • The main stage (with a swipe event listener for moving all the content to the right or the left).
  • Some panels/blocs which I can touch/clic to open another clip.

Source code is close to that :

  • Multitouch.inputMode = MultitouchInputMode.GESTURE;
  • stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE, handleSwipe);
  • bloc1.addEventListener(MouseEvent.CLICK, bloc1Click);
  • bloc2.addEventListener(MouseEvent.CLICK, bloc2Click);
  • etc...

Clicks are working well. Swipe is working well too, but often, when I try to swipe, AIR detect a Touch event first on one of the bloc and cancel the swipe.

Is there a good way to "keep" the touch event before knowing if it's a swipe gesture or not ? Or maybe am Im doing it all wrong?

Many thanks!

This topic has been closed for replies.

1 reply

Known Participant
October 5, 2011

You need create a flag.

I use both in my applications. And work well.

But I create flags.

Multitouch and gesture dont work on  same time.

You need create a action to use one our other.

If you need use both on listener use for object not in stage.

And dont forgout to remove listener is a very important.

ex:

wrong for both

stage.addEventListener(TransformGestureEvent.GESTURE_SWIPE, handleSwipe);

correct for both

myObj.addEventListener(TransformGestureEvent.GESTURE_SWIPE, handleSwipe);

regards

afichouAuthor
Participant
October 5, 2011

Thank your for your help.

Actually, I did forgot to remove the listeners...

So I finally removed them just when the Swipe Event is trapped, and set them back when the Swipe is finish.

And obviously, it works really better now.

Thanks again!