Problem assigning dynamic event handlers to dynamically created clips

I am in a for loop creating clips and assigning a rollover script to each. It works if I hard code gallery_mc1.enterFrame = navGrow; I have pasted the relevant parts of the script below.

this["gallery_mc"+i].onRollOver = function() {
    this["gallery_mc"+i].enterFrame = navGrow();
};

//////////////////////////////////////
navGrow = function () {
if (this._xscale<100) {
trace(“it triggered navGrow”);
this._yscale = this._xscale += 5;
this._y -= 5;
this._x -= 5;
} else {
this.onEnterFrame = null;
}
};

That code looks fine, post the rest of the loop. I usually use a variable to refer to the movieclip for events like this.

Edit: wait… what is enterFrame, shouldn’t that be “onEnterFrame”?

Here is the rest. When you talk about assigning a variable you mean something like this?
temp_mc = this[“gallery_mc”+i];

///////////////////////

import flash.display.BitmapData;
import mx.transitions.Tween;
import mx.transitions.easing.*;
var offset = 0;
for (i=1; i<5; i++) {
// Create imageBmp and attach the bitmap from the library.
//var imageBmp:BitmapData = BitmapData.loadBitmap(“image”+i);
// create movie clip and attach imageBmp
this.createEmptyMovieClip(“gallery_mc”+i, i);
this[“gallery_mc”+i].loadMovie(“images/gallery”+i+".swf");
this[“gallery_mc”+i]._xscale = this[“gallery_mc”+i]._yscale=70;
this[“gallery_mc”+i]._y = 100;
this[“gallery_mc”+i]._x = offset += 3;
offset += 170;//this[“gallery_mc”+i]._width;
trace("offset = " +offset);
trace("gallery_mci = "+this[“gallery_mc”+i]);
trace("gallery_mci._width = "+this[“gallery_mc”+i]._width);
//////////////////////////////////
this[“gallery_mc”+i].onRollOver = function() {
this[“gallery_mc”+i].enterFrame = navGrow();
};
//////////////////////////////////
this[“gallery_mc”+i].onRollOut = function() {
this[“gallery_mc”+i].enterFrame = navShrink();
};
}
this.stop();
///////////////////////////////////////////////
navGrow = function () {
if (this._xscale<100) {
trace(“it triggered navGrow”);
this._yscale = this._xscale += 5;
this._y -= 5;
this._x -= 5;
} else {
this.onEnterFrame = null;
}
};
////////////////////////////////////
navShrink = function () {
if (this._yscale>70) {
this._xscale = this._yscale -= 5;
this._y += 5;
this._x += 5;
} else {
this.onEnterFrame = null;
}
};
//////////////

No, more like this:

import flash.display.BitmapData;
import mx.transitions.Tween;
import mx.transitions.easing.*;
var offset = 0;
for (i=1; i<5; i++) {
   // Create imageBmp and attach the bitmap from the library.
   //var imageBmp:BitmapData = BitmapData.loadBitmap("image"+i);
   // create movie clip and attach imageBmp
   var gallmc:MovieClip = this.createEmptyMovieClip("gallery_mc"+i, i);
   gallmc.loadMovie("images/gallery"+i+".swf");
   gallmc._xscale = gallmc._yscale=70;
   gallmc._y = 100;
   gallmc._x = offset += 3;
   offset += 170;//this._width;
   trace("offset = " +offset);
   trace("gallery_mci = "+this);
   trace("gallery_mci._width = "+this._width);
   //////////////////////////////////
   gallmc.onRollOver = function() {
      this.onEnterFrame = navGrow();
   };
   //////////////////////////////////
   gallmc.onRollOut = function() {
      this.onEnterFrame = navShrink();
   };
}
this.stop();
///////////////////////////////////////////////
navGrow = function () {
   if (this._xscale<100) {
      trace("it triggered navGrow");
      this._yscale = this._xscale += 5;
      this._y -= 5;
      this._x -= 5;
   } else {
      this.onEnterFrame = null;
   }
};
////////////////////////////////////
navShrink = function () {
   if (this._yscale>70) {
      this._xscale = this._yscale -= 5;
      this._y += 5;
      this._x += 5;
   } else {
     this.onEnterFrame = null;
   }
};
//////////////

I switched the whole thing so that it is using a temp variable and it still doesn’t work.
this.createEmptyMovieClip(“gallery_mc”+i, i);
temp_mc = this[“gallery_mc”+i];

Umm… did you read my post?

I tried your method, but I can’t get it to work. I don’t know what to do… I am going to try messing around with a blank clip and duplicateMovieClip. That isn’t working either. UGH!!!