-
Drag and Drop AS3
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. For this activity i have 3 washing baskets (the targets) and a clothes (the draggable items). The clothes are set out into 3 sections - dirty, whites and non washable and there is 1 basket for the 3 sections (non washables basket, dirty basket...)
What i am stuck on is how to get more then multiple draggable item into one 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 myTargetisplayObject = 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|