Hi, I'm having problems with dragging and dropping of multiple objects that are spawned on the stage. I'm trying to make a game where players can drag the draggables between two boxes with slots that they are able to snap into.

This is the image of the stage.

The draggables that are spawned and slots on the stage are put in an array.
public var dropArray:Array = new Array(drop0,drop1,drop2,drop3,drop4);
public var snapArray:Array = new Array(snap0,snap1,snap2,snap3,snap4);

The codes for the snapping into place and the hittest object doesn't seem to work. It seems like the for loop is causing the problem.

private function snapBack(event:MouseEvent):void

for (var j:int=0; j<dropArray.length; j++)
var myTargetName:String=("drop"+j);
var myTargetisplayObject=getChildByName(myTargetName);
var target:MovieClip = event.currentTarget as MovieClip;
var dragIndex:int = dragArray.indexOf(event.currentTarget);

if (item(event.currentTarget).hitTestObject(myTarget)) {


target.x = positionsArray[dragIndex].xPos;
target.y = positionsArray[dragIndex].yPos;



I'm also having problems to not allow them to snap to the slot that already have a draggable in it.

Anyone care to help? Thanks in advance.