Mouse click, attachmovie and for loop issue

I have 3 buttons and when I click them the attach movies corresponding to them from the library should show up. Issue is with for loops. It stops at last number.
What should I do or use for loop so that when I click my invisible buttons, movie corresponding to them show up? and only that movie show up, not anyone else.

buttonArray = [btn,btn1,btn2]; //mouse click button
movieArray = [“mypopmc”,“mypopmc1”,“mypopmc2”]; //movie name;
mArray1 = [mypop_mc,mypop_mc1,mypop_mc2,]; //movie instance name
//dynamic text instance for 3 movies are y1,y2 and y3

for(n=0;n<buttonArray.length;n++) {
buttonArray[n].onRelease = function(){
buttonArray[n]._parent.attachMovie(movieArray[n], mArray1[n], 0);
_root[mArray1[n]]._x=250;
_root[mArray1[n]]._y=250;
mArray1[n].y1.text = “whatever value”;
mArray1[n].y2.text = “whatever value”; //and so on
}
}

How could I create the for loop so that with every mouse click it shows the corresponding movie and text in it. Anyone???
It should show only 1 movie at a time with 1 mouse click on the invisible button (I meant corresponding movie).

Thanks East Coast. You have solved my issue :). Your time is very much appreciated. Regards to you :slight_smile:

for(n=0;n<buttonArray.length;n++) {
buttonArray[n].id = n;//assign a value to the button
buttonArray[n].onRelease = function(){
this.attachMovie(movieArray[this.id]);//recall the value
//etc use this.id to get values out of the external arrays inside the onRelease handler, 'n' has no meaning outside the loop execution.
}
}