0

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

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

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

4

2 回答 2

1

您应该指定dragProxyformovieClip来保存它的实例而不是固定图像。

于 2011-04-29T12:45:40.483 回答
1

要使用 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 );
}
于 2011-04-29T12:55:17.583 回答