2011-04-29 106 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來保存它的一個實例,而不是一個固定的圖像。