Hi,
Im new to AS3 and was wondering if there is anyone out there that can help me with this...
Im creating a drag and drop Flash activity where there is 1 target and multiple draggable items. In my case I have 4 apples and I want to be able to put all apples into the same basket. I can get the draggable item into one target but i cannot get multiple draggable items into one single target...
Here is my code...
import caurina.transitions.*; //import flash.geom.Rectangle;
//var myBoundaries:Rectangle=new Rectangle(68.65,637.8,100,50);
circle1_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag); circle1_mc.addEventListener(MouseEvent.MOUSE_UP, drop);
function drag(event:MouseEvent):void { //event.target.startDrag(true, myBoundaries); event.target.startDrag(); }
function drop(event:MouseEvent):void { event.target.stopDrag(); var myTargetName:String = "target" + event.target.name; var myTarget:DisplayObject = getChildByName(myTargetName); if(event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){ //trace("hit");
/*Remove the event listeners when a peg is correctly placed*/
event.target.removeEventListener(MouseEvent.MOUSE_DOWN, drag);
event.target.removeEventListener(MouseEvent.MOUSE_UP, drop);
event.target.buttonMode = false;
/*Adjust the peg’s position when it is correctly placed*/
event.target.x = myTarget.x;
event.target.y = myTarget.y;
/*add tween*/
Tweener.addTween(circle1_mc,{x:68.65,y:637.8,time:1,transition:"easeIn"});
} else {
//trace("try again");
/*add tween*/
Tweener.addTween(circle1_mc,{x:97.9,y:64.95,time:1,transition:"easeIn"});
}
}
circle1_mc.buttonMode = true;
Hope to hear from you soon