i wanna write a function for the onPress handler for a movieclip that will be created dynamically… how do i do it? this is what i’m doing:
only the ending part of this loop is relevant, where i am writing the thisMC.onpress function. The trace text never appears…
for (var i = 0; i<galleryLength; i++)
{
var thisMC:MovieClip = this.createEmptyMovieClip("image"+i+"_mc", i);
loadMovie(gallery_array*.src, thisMC);
thisMC._x = 50*xPos+adjust;
xPos++;
thisMC._y = 50*yPos;
thisMC._xscale = 10;
thisMC._yscale = 10;
trace(thisMC+" "+thisMC._x+" "+thisMC._y);
if ((i+1)%5 == 0)
{
yPos++;
xPos = 0;
}
//Here lies the problem:
thisMC.onPress = function()
{
trace("Pressed "+this);
}
}
this whole loop is inside the onClipEvent(load) of another clip. So when that clip is loaded, this code is executed…