# Passing variable question - Pulling my hair out

**URL:** <https://forum.kirupa.com/t/passing-variable-question-pulling-my-hair-out/226371>\
**Category:** flash\
**Created:** [May 20, 2007, 9:07pm UTC](https://forum.kirupa.com/t/passing-variable-question-pulling-my-hair-out/226371 "2007-05-20T21:07:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tazboy](https://avatars.discourse-cdn.com/v4/letter/t/3d9bf3/32.png) [@tazboy](https://forum.kirupa.com/u/tazboy)\
**Post date:** [May 20, 2007, 9:07pm UTC](https://forum.kirupa.com/t/passing-variable-question-pulling-my-hair-out/226371/1 "2007-05-20T21:07:13Z")

</div>

How do I get the for-loop’s i variable to be available inside the onLoadInit function???

```auto
for (var i = 0; i<nTotalPics; i++) {

    main.createEmptyMovieClip("container"+i,i);
    var container:MovieClip = main["container"+i];
    container.createEmptyMovieClip("pic"+i,i);
    var pic:MovieClip = container["pic"+i];
    
    // load images
    mcl.loadClip(astrImages*,pic);

    // Thumbnail structure // USED to be pic. , now it's container.
    container._x = (i%columns)*contWidth;
    var newRow = Math.floor(i/columns);
    container._y = newRow*contHeight;

}

// when the image finishes loading
mclListener.onLoadInit = function(pic:MovieClip) {    
        // I NEED TO USE THE FOR-LOOPS VARIABLE HERE. How??
}
// add the listener to the MovieClipLoader Object
mcl.addListener(mclListener);

```

This has been bugging me for about 2 months now.:sen: Maybe I’m looking at it the wrong way, but I need to create more things in the onLoadInit function using a for-loop.

Any ideas would be greatly appreciated
