Problems assigning actions to buttons in a loop

i’m pulling my hair out over this one. :frowning:

I have is a movie with a button in it called button.
i’ve duplicated the movie (manually) several times on the stage.
the movies have been given instance names of movie1, movie2 etc.
i’ve then used actionscript to assign actions to the buttons.
i have the following code:


for (i = 1; i < 6; i++)
{
 this["movie" + i].button.onRelease = function() 
 { 
   abc(i); 
 }; 
}

function abc(num)
{
 trace(num);
}

the problem is that everytime one of the buttons is pressed, it prints out 6.
i’ve spent hours on this problem. :frowning:
i couldn’t see that i’d done anything wrong.

but now having simplified the code…
i think there is a problem with the passing of the arguement in the fucntion call within the button.

i’ve attached the Flash file. (mx2004 format.)
i’m kinda desperate and need to solve this problem asap. :frowning:

any help/suggestions would be appreciated.

thanks.

OM