PDA

View Full Version : onLoadInit help ?


tazboy
05-05-2007, 07:08 PM
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.

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[i], 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.

TheCanadian
05-05-2007, 07:56 PM
Wrong forum buddy ;)

tazboy
05-05-2007, 08:01 PM
Why is that?
Can you be more specific?

This is ActionScript 3.

devonair
05-05-2007, 10:12 PM
What you've posted is AS2.. Did you want it in AS2 or AS3?