# onLoadInit help?

**URL:** <https://forum.kirupa.com/t/onloadinit-help/224828>\
**Category:** Uncategorized\
**Created:** [May 5, 2007, 11:08pm UTC](https://forum.kirupa.com/t/onloadinit-help/224828 "2007-05-05T23:08:02Z")\
**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 5, 2007, 11:08pm UTC](https://forum.kirupa.com/t/onloadinit-help/224828/1 "2007-05-05T23:08:02Z")

</div>

I’m making a gallery. I’m only at the beginning of doing so but I’m having a problem passing variables into 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, i );

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

}

// when the image finishes loading
mclListener.onLoadInit = function(pic:MovieClip){
    **main.container3.createTextField("txtQuan", 1, 0, 100, 80, 20);
    var txtQuan:TextField = main.container3.txtQuan;**
    txtQuan.text = "How many : ";
}

// add the listener to the MovieClipLoader Object
mcl.addListener(mclListener);

```

The code I’m having an issue with is in bold. After the images have been loaded I want to add a TextField underneath them.  
Why can’t I use the “i” value from the for loop to create textfields. I want to do this: \*\*main[“container”+i].createTextField(“txtQuan”, 1, 0, 100, 80, 20); . \*\*Why can’t I do this? I’m a little lost when it comes to listeners.

Thanks for any ideas you have.
