Search code examples
actionscript-3apache-flexflash-builderflex4.6

Flex 4.6 Scroller - Is it possible to disable scrolling temporarily through Actionscript?


I am trying to make a mobile app that would allow a drag and drop of certain elements using startDrag() and stopDrag(). These elements are enclosed inside of a spark scroller. I would like to disable the scroller when someone is interacting with the draggable objects, but can't seem to get the scroller to not respond.

Here are the things I have tried.

protected function draggableObjectOnMouseBegin(e:MouseEvent):void {
    scrollerObject.enabled = false;
    scrollerObject.mouseEnabled = false;
    scrollerObject.mouseFocusEnabled = false;
    draggableObject.setElementIndex(e.currentTarget as IVisualElement, dragabbleObjectGroup.numElements-1);
    e.currentTarget.startDrag();
}

But the scroller will not stop scrolling. Am I missing something or is there no wat to temporarily stop a scrollers ability to scroll to allow for drag and drop type operations on objects enclosed in a scroller.


Solution

  • I just trying to do exactly this this myself and I think I have a working answer.

    What you need to do is set the verticalScrollPolicy (and/or horizontal). You do this via the setStyle method:

    scrollerObject.setStyle('verticalScrollPolicy', ScrollPolicy.OFF);
    

    Obviously to re-enable scrolling just set the policy back to ON.