# Help with code drag an drop

**URL:** <https://forum.kirupa.com/t/help-with-code-drag-an-drop/286460>\
**Category:** flash\
**Created:** [April 15, 2009, 7:40pm UTC](https://forum.kirupa.com/t/help-with-code-drag-an-drop/286460 "2009-04-15T19:40:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rboyart](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@rboyart](https://forum.kirupa.com/u/rboyart)\
**Post date:** [April 15, 2009, 7:40pm UTC](https://forum.kirupa.com/t/help-with-code-drag-an-drop/286460/1 "2009-04-15T19:40:38Z")

</div>

Hello!

I’m trying to do a “drag and drop” with an array, but i can only move everything at the same time, and i’ll like to move each element of the array separately.

this is my code, and i have a movieclip in the library with export for actionscript(Rect) :

/////////  
var arr:Array = new Array();  
for (var i:int = 0; i \< 6; i++) {  
var a:Rect = new Rect();  
arr.push(a);  
addChild(a);  
a.x+=i_20;  
a.y+=i_30;  
}

stage.addEventListener(MouseEvent.MOUSE\_DOWN, drag);  
stage.addEventListener(MouseEvent.MOUSE\_UP, drop);

function drag(event:MouseEvent):void{

```
this.startDrag();
this.parent.addChild(this);

```

}

function drop(event:MouseEvent):void{

```
this.stopDrag();

```

}

//////////

thanks for all kind of help.  
cheers.
