2011-04-29 29 views
0

为了提高我们想要的用户体验有转向wheel-的动画影片剪辑,并有拖动的能力,并在任何地方砸在限定区域的能力柔性:能够拖动+下降一个影片剪辑

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

我们该如何做拖拽。我看到的例子,迎合只丢弃图像。再次感谢

回答

1

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

这是一些good instructions。要复制到相关部分:

使一个组件可拖动

  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); 
} 
+0

Thanks-我现在这样做是为了一个图像 - 明白了,我只需要创建一个UI容器,并把我的SWC中觉得─和图像相同的拖放逻辑将申请该UI容器。 – RG1967 2011-05-11 18:14:55

1

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