簡體   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