AS3 - 在滚动窗格中拖动项目

发布于 2024-11-02 04:29:36 字数 739 浏览 0 评论 0原文

我使用 Flash ScrollPane 组件来保存一叠垂直的影片剪辑。我已经实现了允许用户在垂直堆栈中上下拖放这些影片剪辑的功能,以便他们可以重新排列顺序。当用户将影片剪辑拖向滚动窗格的底部时,就会出现我的问题,我希望内容滚动,以便用户可以将拖动的影片剪辑放在不适合滚动窗格可视区域的项目下方。

当拖动的影片剪辑朝向窗格底部时,我尝试通过增加verticalScrollPosition来自动滚动窗格,但这不起作用,因为拖动的影片剪辑是滚动窗格内容的一部分,并与其余内容一起移动。拖动的影片剪辑与其余内容一起向上移动,并且不再位于用户光标下方:

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

          if(draggedY > this.height - 30 && draggedY > this.height - 25){
            verticalScrollPosition ++;
            //e.currentTarget.y ++;
        }   

可能不是对我的问题的最佳描述,但希望您能明白这一点。如果您需要任何说明,请告诉我。我想我可能需要从窗格的“可滚动”内容中排除拖动的影片剪辑,但我不知道如何解决这个问题。

任何帮助表示赞赏。

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.currentTarget.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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

摇划花蜜的午后 2024-11-09 04:29:36

如果我理解正确,我可以建议您两个解决方案:

  1. 当鼠标滚轮旋转时滚动窗格,而不是当用户将影片剪辑拖到底部时滚动窗格。

  2. 开始拖动后,将影片剪辑从窗格中删除。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文