Y drop VA SER EL OBJETO A ARRASTRAR
Código :
//Array to hold the target instances, the drop instances, //and the start positions of the drop instances. var hitArray:Array = new Array(hitTarget111,hitTarget1222); var dropArray:Array = new Array(drop111,drop1222); [code]var positionsArray:Array = new Array();[/code] //This adds the mouse down and up listener to the drop instances //and add the starting x and y positions of the drop instances //into the array. for (var i:int = 0; i < dropArray.length; i++) { dropArray[i].buttonMode = true; dropArray[i].addEventListener(MouseEvent.MOUSE_DOWN, mdown); dropArray[i].addEventListener(MouseEvent.MOUSE_UP, mUp); positionsArray.push({xPos:dropArray[i].x, yPos:dropArray[i].y}); } //This drags the object that has been selected and moves it //to the top of the display list. This means you can't drag //this object underneath anything. function mdown(e:MouseEvent):void { e.currentTarget.startDrag(); setChildIndex(MovieClip(e.currentTarget), numChildren - 1); } //This stops the dragging of the selected object when the mouse is //released. If the object is dropped on the corresponding target //then it get set to the x and y position of the target. Otherwise //it returns to the original position. function mUp(e:MouseEvent):void { var dropIndex:int = dropArray.indexOf(e.currentTarget); var target:MovieClip = e.currentTarget as MovieClip; target.stopDrag(); if (target.hitTestObject(hitArray[dropIndex])) { target.x = hitArray[dropIndex].x; target.y = hitArray[dropIndex].y; }else{ target.x = positionsArray[dropIndex].xPos; target.y = positionsArray[dropIndex].yPos; } } restar.addEventListener(MouseEvent.CLICK, backObjects); function backObjects(e:MouseEvent):void{ for(var i:int = 0; i < dropArray.length; i++){ if(dropArray[i].x == hitArray[i].x && dropArray[i].y == hitArray[i].y){ dropArray[i].x = positionsArray[i].xPos; dropArray[i].y = positionsArray[i].yPos; anotar.text=""; } } } /*FIN DRAG DROP*/