繁体   English   中英

flex:能够拖放一个movieclip

[英]flex: Ability to drag+drop a movieclip

为了改善用户体验,我们希望能够拥有一个转动轮子的动画影片剪辑,并且能够将其拖放到定义区域的任何位置

我们已将旋转轮构建为 swc 文件。

我们如何进行拖放。 我见过的示例仅适用于丢弃图像。 再次感谢

您应该为movieClip指定dragProxy以保存它的实例而不是固定图像。

要使用 Flex 类进行拖放,您需要将该 movieClip 包装在UIComponent中; 其中包含与拖放相关的所有事件。

这里有一些很好的说明 复制相关部分:

使组件可拖动

  1. 为 MouseEvent.MOUSE_DOWN 添加监听器
  2. 确定拖动启动器并移交给 DragManager

要启动拖放操作,您需要一个 MouseEvent 来拖动组件。

public function makeDraggable( component:IUIComponent ):void
{
   // a mouseDown event will start the drag
   component.addEventListener( MouseEvent.MOUSE_DOWN, beginDrag );
}

public function beginDrag( mouseEvent:MouseEvent ):void
{
   // the drag initiator is the object being dragged (target of the mouse event)
   var dragInitiator:IUIComponent = mouseEvent.currentTarget as IUIComponent;

   // the drag source contains data about what's being dragged
   var dragSource:DragSource = new DragSource();

   // ask the DragManger to begin the drag
   DragManager.doDrag( dragInitiator, dragSource, mouseEvent, null );
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM