AS3 - 在滚动窗格中拖动项目
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确,我可以建议您两个解决方案:
当鼠标滚轮旋转时滚动窗格,而不是当用户将影片剪辑拖到底部时滚动窗格。
开始拖动后,将影片剪辑从窗格中删除。
If I understood you correctly I can advice you two solutions:
Scroll your pane when mouse wheel is spun over instead of scvrolling it when the user drags movie clip to bottom.
Remove movie clip from pane after you start dragging it.