all groups > flash actionscript > december 2005 >
You're in the

flash actionscript

group:

Same onPress for Multiple MCs?


Same onPress for Multiple MCs? Typhlosion
12/18/2005 9:24:50 PM
flash actionscript:
I have a movie with about 40 movie clips, named itm0-itm40. Now, I want all of
these to have the same kind of onPress function - I want it to print the value
of an array with that very number (0-40).
So, if I click the movie clip itm23, I want it to display the value of
MyArray[23] (in a text box).

Can this be done without writing the same function over and over again 40
times?
Re: Same onPress for Multiple MCs? kglad
12/18/2005 9:50:48 PM
for (var j=0;j<=40;j++){
_root["itm"+j].jvar=j;
_root["itm"+j].onPress=function(){
yourTF.text=MyArray[this.jvar];
}
Re: Same onPress for Multiple MCs? Typhlosion
12/18/2005 10:13:44 PM
Re: Same onPress for Multiple MCs? kglad
12/19/2005 12:35:14 AM
AddThis Social Bookmark Button