Dynamic referencing?

If I have created empty movie clips using duplicateMovieClip(), how do I reference the movie clip instances. For instance lets say I have dupliacted 10 clips, how would I get an action to be fired when the user clicks on one of these instances? I have tried :

this[“mc”+z].onRelease = function(){},

but it does not work.

:2c:

myMovieClip.duplicateMovieClip(newname, depth [,initObject])

newname is used to give a unique instance name.

for say 10 different MCs through for loop would be

for(var k = 1; k<=10 ; k++){
***newname ***= “MC”+k+"_mc";
myMovieClip.duplicateMovieClip(newname, depth [,initObject])
}

In this case u will have 10 mc with instance name MC1_mc , MC2_mc
MC3_mc, … so on .

Dhiraj

[AS]_mcButt = eval("_mcphone"+i);

_mcButt.onRollOver = function() {
l = this._name.lastIndexOf(“e”);
number = Number(this._name.substr(l+1, 2));
dosometing("_mcphone"+number);
};
[/AS]

this is solution I made
problem with creating mulitple buttons that last value of variable in for loops stays so you need to retake number of your button
I am doing that with getting Number from button instance name
lastIndexOf(“e”) returns last index of letter before numbers and in case of _mcphone that is e
if you have buttons instance names like MCxx xx is number than use lastindex of C

I sugest placing number at the end of instane names not in middle

I do it like this:

for(var k = 1; k<=10 ; k++){
   var dupeclip:MovieClip = myMovieClip.duplicateMovieClip(newname, depth [,initObject]) 
   dupeclip._x = 25
   dupeclip._y = 100
   dupeclip.onRelease = function(){
      trace("You pressed "+this)
      //etc...
   }
} 

it’s cool
in my case I must know what button number user pressed
and you can’t reference etc. like mcButton5.onRelease = function() {
showPhone(5);
}

I can respect your way of doing it, it’s actually a better way of doing it mrsteel. I just offered my way to him because it’s easier to understand when viewing it for the first time.

If i was for example to use “dupeclip” within that trace, it wouldn’t work.

for(var k = 1; k<=10 ; k++){
   var dupeclip:MovieClip = myMovieClip.duplicateMovieClip(newname, depth [,initObject]) 
   dupeclip._x = 25
   dupeclip._y = 100
   dupeclip.onRelease = function(){
      trace("You pressed "+dupeclip)
      //etc...
   }
}

So it’s kinda stupid anyway…:slight_smile:

LOL
offtopic: what’s going on with nameless

[ot]Nameless == stalled. Still nobody contributing but me, paddy and josh.:)[/ot]