Simple Drag and Drop with Condition (multiple object and target)?

hi! :snug: i’m new in as3 and we’re on a research project, and currently i’m working on a drag and drop game. The concept is to drag the animals to their home. (e.g. the goat,carabao,dog must be dragged to the land) and I also need score, I don’t know where to put it.please help :emb: here’s my code which only support 1 object and without condtion and score :frowning:

[SIZE=2]var dragArray:Array = [turtle_mc, goat_mc, eagle_mc, shark_mc ];[/SIZE]
[SIZE=2]var matchArray:Array = [land_match, air_match, water_match, landwater_match];[/SIZE]
[SIZE=2]var posArray:Array = [ {x:0, y:0}, {x:518.30, y:0}, {x:1.30, y:268.65}, {x:519.55, y:270.10} ];[/SIZE]
[SIZE=2]
[/SIZE]
[SIZE=2]
[/SIZE]
[SIZE=2]var currentClip:MovieClip;[/SIZE]
[SIZE=2]var startX:Number;[/SIZE]
[SIZE=2]var startY:Number;[/SIZE]
[SIZE=2]
[/SIZE]
[SIZE=2]for(var i:int = 0; i < dragArray.length; i++) {[/SIZE]
[SIZE=2] dragArray*.buttonMode = true;[/SIZE]
[SIZE=2] dragArray*.addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);[/SIZE]
[SIZE=2] //matchArray*.alpha = 0.2;[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]
[/SIZE]
[SIZE=2]function item_onMouseDown(event:MouseEvent):void {[/SIZE]
[SIZE=2] currentClip = MovieClip(event.currentTarget);[/SIZE]
[SIZE=2] startX = currentClip.x;[/SIZE]
[SIZE=2] startY = currentClip.y;[/SIZE]
[SIZE=2] addChild(currentClip); //bring to the front[/SIZE]
[SIZE=2] currentClip.startDrag();[/SIZE]
[SIZE=2] stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]
[/SIZE]
[SIZE=2]function stage_onMouseUp(event:MouseEvent):void {[/SIZE]
[SIZE=2] stage.removeEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);[/SIZE]
[SIZE=2] currentClip.stopDrag();[/SIZE]
[SIZE=2] var index:int = dragArray.indexOf(currentClip);[/SIZE]
[SIZE=2] var matchClip:MovieClip = MovieClip(matchArray[index]);[/SIZE]
[SIZE=2] if(matchClip.hitTestPoint(currentClip.x, currentClip.y, true)) {[/SIZE]
[SIZE=2] //a match was made! position the clip using the posArray values:[/SIZE]
[SIZE=2] currentClip.x = posArray[index].x;[/SIZE]
[SIZE=2] currentClip.y = posArray[index].y;[/SIZE]
[SIZE=2] //make it not draggable anymore:[/SIZE]
[SIZE=2] currentClip.removeEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);[/SIZE]
[SIZE=2] currentClip.buttonMode = false;[/SIZE]
[SIZE=2] } else {[/SIZE]
[SIZE=2] //match was not made, so send the clip back where it started:[/SIZE]
[SIZE=2] currentClip.x = startX;[/SIZE]
[SIZE=2] currentClip.y = startY;[/SIZE]
[SIZE=2] }[/SIZE]
[SIZE=2]}[/SIZE]