# Using for loop for drag drop

**URL:** <https://forum.kirupa.com/t/using-for-loop-for-drag-drop/279127>\
**Category:** Uncategorized\
**Created:** [January 9, 2009, 8:01pm UTC](https://forum.kirupa.com/t/using-for-loop-for-drag-drop/279127 "2009-01-09T20:01:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gencoglu](https://avatars.discourse-cdn.com/v4/letter/g/898d66/32.png) [@gencoglu](https://forum.kirupa.com/u/gencoglu)\
**Post date:** [January 9, 2009, 8:01pm UTC](https://forum.kirupa.com/t/using-for-loop-for-drag-drop/279127/1 "2009-01-09T20:01:35Z")

</div>

Hi, I have many MCs on the stage ,I just dont want to paste the same code to all MCs one by one…so I want to use the following loop but not sure where to paste the following code…could anyone help ?  
thanks

```php

myArray=new Array("mc1","mc2","mc3","mc4","mc5","mc6","mc7","mc8","mc9","mc10")
for(i=0; i<=myArray.length; i++){
myArray*.onPress=function(){
this.startDrag();
}
myArray*.onRelease=function(){
this.stopDrag();
}
}
 
 
 

```
