/ Published in: ActionScript 3
simple drag and drop of an object on to a target. It will trace a 'success' message when the object is placed on the target item after being dragged and released.
Expand |
Embed | Plain Text
dragItem_mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); dragItem_mc.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); function mouseDownHandler(e:MouseEvent):void { var obj = e.target; obj.startDrag(); } function mouseUpHandler(e:MouseEvent):void { var obj = e.target; var target = obj.dropTarget; if(target != null && target.parent == dropTarget_mc) { trace('target hit'); } obj.stopDrag(); }
Comments
Subscribe to comments
You need to login to post a comment.

You better assign the MOUSE_UP listener to the stage, sometimes the mouse can be outside the dragged object