开发者

AS3 - Dragging Items within a Scrollpane

I'm using the Flash ScrollPane component to hold a vertical stack of movieclips. I have implemented functionality to allow the user to drag and drop these movieclips up and down within the vertical stack so they can rearrange the order. My problem occurs when the user drags a movieclip towards the bottom of the scrollpane, I want the content to scroll so the user can drop the dragged movieclip below items which don't fit within the viewiable area of the scrollpane.

I attempted to automatically scroll the pane by incrementing the verticalScrollPosition when the dragged movieclip is towards the bottom of the pane, but this doesn't work as the dragged movieclip is part of the content of the scrollpane and gets moved with the rest of the content. The dragged movieclip moves up with the rest of the content and is no longer under the users cursor:

        private function onDragged (e : Event) : void {
          var draggedY : Number = ComponentHolder(e.currentTarget).y;           

          if(draggedY > this.height - 30 && draggedY > this.height - 25){
            verticalScrollPosition ++;
            //e.curr开发者_JS百科entTarget.y ++;
        }   

Probably not the best description of my problem but hopefully you get the idea. If you need any clarification please let me know. I think I possibly need to exclude the dragged movieclip from the 'scrollable' content of the pane but I'm not sure how to go about this.

Any help is appreciated.


If I understood you correctly I can advice you two solutions:

  1. Scroll your pane when mouse wheel is spun over instead of scvrolling it when the user drags movie clip to bottom.

  2. Remove movie clip from pane after you start dragging it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜