# Trouble with onPress and drag inside a loop \[Flash8\]

**URL:** <https://forum.kirupa.com/t/trouble-with-onpress-and-drag-inside-a-loop-flash8/242114>\
**Category:** flash\
**Created:** [October 22, 2007, 4:53pm UTC](https://forum.kirupa.com/t/trouble-with-onpress-and-drag-inside-a-loop-flash8/242114 "2007-10-22T16:53:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wallmic](https://avatars.discourse-cdn.com/v4/letter/w/82dd89/32.png) [@wallmic](https://forum.kirupa.com/u/wallmic)\
**Post date:** [October 22, 2007, 4:53pm UTC](https://forum.kirupa.com/t/trouble-with-onpress-and-drag-inside-a-loop-flash8/242114/1 "2007-10-22T16:53:26Z")

</div>

Hi all,

I am trying to take a user input word, in this case “joe,” and add the movie clips representing those letters to the stage in a jumble. I then want the clips to be able to be dragged into correct order. Below is what I have. Everything works but the dragging bit.

I am very much a newbie. My instinct is telling me that the problem is that this is happening in a “for loop” and that the dragging ability is no longer possible at the end of the loop. Is this the case? If so, is there a work around.

```auto
var my_str:String = new String("joe");
    var my_array:Array = my_str.split("");
    for (var i = 0; i<my_array.length; i++) {
        var xran:Number = 100+random(100);
        var yran:Number = 100+random(100);
        _root.attachMovie((my_array*),(my_array*)+i,i,{_x:xran, _y:yran});
        var xyz = (my_array*)+i;
        xyz.onPress = function():Void {
            this.startDrag(true);
        };
        xyz.onRelease = function():Void {
            this.stopDrag();
        };
    }

```

Thanks. I appreciate the help with a newbie.
