I have a loop and I am trying to create dynamic functions, each which contains a different variable. The problem is, once the loop finishes, it references the function created last.
I trimmed the code down below, but it should illustrate what I am trying to do.
// start segment
for(var j=0;j<ary.length;j++) {
var img_mc:MovieClip = new MovieClip();
var temp_str:String = "testing_" + j;
launchBanner(img_mc,temp_str);
}
// end segment
function launchBanner(object:MovieClip, temp_str:String):void {
var f:Function = new Function();
f = function(e:MouseEvent) { trace(mc_url); };
object.addEventListener(MouseEvent.CLICK, f );
}