I’m creating a menu from mcs loaded from the library, I want to assign an onRelease function to each of the menu items which i’m storing in a temporary array when created… basically this: -
//loop and attach menu items for the number of items in layLength
for(var i=0, j=0; i < layLength; i++){
var temp = container.attachMovie("menuItemMC", "menuItemMCxxx" + i, i);
temp.img = as2obj.boat.img*.attributes.file; //some xml data
tempArray.push(temp);
y++;
}
//Assign onRelease events to each menu item loaded
for(g in tempArray){
tempArray[g].onRelease = function() {
trace("I am associated with " + tempArray[g].img);
}
}
the problem is the functions assigned to the created movieclips will just default to the current value of ‘g’ I.e. when trace is triggered it will trace the tempArray value of whatever g is currently, I want it to remember the value at the time the function is assigned to the movie.
Sorry for the poor explanation, my english is bad… I’m british :S
Thanks
Dan