Here is a working script to drag drop a ball from the stage into another target mc:
ball.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
stage.addEventListener(MouseEvent.MOUSE_UP, dropIt);
function pickUp(event:MouseEvent):void{
var ballPoint:Point = ball.parent.localToGlobal( new Point(ball.x, ball.y) );
ball.parent.removeChild(ball);
addChild(ball);
ball.x = ballPoint.x;
ball.y = ballPoint.y;
ball.startDrag();
}
function dropIt(event:MouseEvent):void{
ball.stopDrag();
if(!event.target.dropTarget) { return };
var dropT:MovieClip = event.target.dropTarget.parent;
var ballPoint:Point = dropT.globalToLocal( new Point(ball.x, ball.y) );
ball.parent.removeChild(ball);
dropT.addChild(ball);
ball.x = ballPoint.x;
ball.y = ballPoint.y;
}
It works well but I'm new to AS3 and I am having difficulty amending this script to drag the ball out of a parent mc (instead of the stage) and onto another mc (the target mc). To explain: imagine a ball, a box, a tri, + more shapes all within a scrolling mc (initial parent), the user scrolls to select a shape, then drag-drops onto a target mc on the stage.
The scrolling is no problem, but how would you amend the script above so that the ball can start inside a parent mc rather than on the stage itself?
Any suggestions welcome.