Skip to main content
Participant
March 7, 2012
Answered

swipe event handling

  • March 7, 2012
  • 1 reply
  • 1606 views

Hello all!

I need some help with swiping in my mobile project....

O want swipe between views. So I add  addEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe); to my View init function

A it is OK. Its work!

But, I also added <s:List> (horizontal) to view. And when i try scroll (swipe) that List horizontally with finger, i also swipe/scroll my View to another!

I understand that it is something with event bubbling , but I don't know how to fix this. I try use removeEventListener(TransformGestureEvent.GESTURE_SWIPE, onSwipe) on navigator.activeView : View when I startTouch List. No positive effect.

So. I would glad for any help.

This topic has been closed for replies.
Correct answer Phil Flash

Hi,

To swipe between views, there is a new atttibute "pageScrollingEnabled" for List in Flex 4.6

For more information, see Jason's Flex blog:

http://blogs.adobe.com/jasonsj/2011/11/mobile-list-paging-with-page-indicator-skin.html

For your example :

- use addEventListener in viewActivate method,

- use removeListener in viewDeactivate method

- in the method for TransformGestureEvent.GESTURE_SWIPE,

test the target and use event.preventDefault to cancel the event.

- in the method onSwipe, test isDefaultPrevented

  (in some case, systemManager that redispatches a cancellable

   version of an event)

      protected function onSwipe(event:TransformGestureEvent):void

      {

          if (event.isDefaultPrevented()) return;

        ...

And if your are problems, post a code snippet...

Philippe

1 reply

Phil FlashCorrect answer
Inspiring
March 9, 2012

Hi,

To swipe between views, there is a new atttibute "pageScrollingEnabled" for List in Flex 4.6

For more information, see Jason's Flex blog:

http://blogs.adobe.com/jasonsj/2011/11/mobile-list-paging-with-page-indicator-skin.html

For your example :

- use addEventListener in viewActivate method,

- use removeListener in viewDeactivate method

- in the method for TransformGestureEvent.GESTURE_SWIPE,

test the target and use event.preventDefault to cancel the event.

- in the method onSwipe, test isDefaultPrevented

  (in some case, systemManager that redispatches a cancellable

   version of an event)

      protected function onSwipe(event:TransformGestureEvent):void

      {

          if (event.isDefaultPrevented()) return;

        ...

And if your are problems, post a code snippet...

Philippe

Participant
March 10, 2012

Hey, Thx a lot!

I used exacly preventDefault and all work (I use it on my List)...

And yes, I know that using List to swipe between content is better way. But what about memory consuption when i put let's say 80 items (fullscreen background, scrolling text, images or multimedia content, all from DataProvider as assets)  in that List? It's possible to keep reasonable performance?

Yes, I try build simple products catalog as my first app in Adobe Technology