Search code examples
androidactionscript-3apache-flexflashdevelopgestures

Differentiate between scroll and swipe in Flex Mobile Application


Is it possible to differentiate between a Horizontal Swipe gesture and a Horizontal Scroll in Flex Mobile. I have a List (horizontal layout) with no listener attached to it, and a view, with a GestureSwipe listener attached to it, when I try to scroll the list the swipe gesture gets fired, obviously. I have tried to add a gesture event listener to the list and call a function with event.stopPropagation() which does stop the gesture being fired in the view, but as the list takes up 85% of the screen real-estate this makes it quite difficult to make the view event fire, which defeats the object of what I want to do.

Is there a way to tell the 2 actions apart, speed, duration or something else?

Using FlashDevelop, and Flex SDK v4.14.1, Air 17.0, building for Android

Thanks


Solution

  • Ok, so I can't find out how to differentiate between the 2 events, however there seems to be a workaround, not a good one, but I suppose it could work, however I see an issue with adding the event listener after the list has scrolled to it's furthest point, you would require another scroll/swipe action to make the view transition, not a good experience for the users.

    list.scroller.viewport.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE,propertyChangeHandler );
    
    protected function propertyChangeHandler(event:PropertyChangeEvent):void
    {
        if (event.property == "horizontalScrollPosition" )
        {
            if (event.newValue == (event.currentTarget.measuredWidth - event.currentTarget.width )) {
                    navigator.pushView(view.RightView);
            }
            if(event.newValue == 0){
                    navigator.pushView(view.LeftView);
            }
        }
    }
    

    Does anyone have any thoughts on this approach?