# Duplicate movie clip instance naming

**URL:** https://forum.kirupa.com/t/duplicate-movie-clip-instance-naming/34869
**Category:** flash
**Created:** [November 7, 2003, 7:14am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-instance-naming/34869 "2003-11-07T07:14:41Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mopie](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mopie](https://forum.kirupa.com/u/mopie)
#### Post date: [November 7, 2003, 7:14am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-instance-naming/34869/1 "2003-11-07T07:14:41Z")

</div>

Hi, I’ve got a movie where I duplicate a Button a bunch of times using the DuplicateMoiveClip command. This works fine and dandy.

however I now need (on the rollover) for each button to know its name, but “\_name” gives the name of the instance, and since these buttons were created dynamically, the instance name is not created. And when a Trace is put on the “\_name” on the rollover state of the generated btn it gives me the name of the movie clip that the button is in (so all the buttons have the same name)

1- is there some way to define the instance name of a generated symbol?

2- can I pull the name from the actuall name of the symbol?

or have I missed something…

thanks!

-Mopie

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 7, 2003, 7:45am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-instance-naming/34869/2 "2003-11-07T07:45:40Z")

</div>

can you be more detailed or give an example?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 7, 2003, 7:54am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-instance-naming/34869/3 "2003-11-07T07:54:51Z")

</div>

Ok this is the code for creating the Buttons (it takes the first button, duplicates it, moves it over 10px, does this till the row is full, then continues till the grid is full… and it works lovley)

btn\_xpos = 5.5;  
btn\_ypos = 5.5;  
growth = 1;

function place\_btns(){  
duplicateMovieClip(“btn”,“btn”+growth,growth);  
this[“btn”+growth].\_x = btn\_xpos;  
this[“btn”+growth].\_y = btn\_ypos;  
btn\_xpos = btn\_xpos + 10;  
if (btn\_xpos \>= 105.5){  
btn\_ypos = btn\_ypos + 10;  
btn\_xpos = 5.5;  
}  
}

for(i=1; i\<=70; i++){  
growth ++;  
place\_btns()  
}

What I need is when you rollover the newly made buttons, I need it to know who it is…

if I use this code

on (rollOver) {  
trace(this.\_name);  
}

I get the name of the instance for the movie the buttons are in

if I use

on (rollOver) {  
trace(\_name);  
}  
I get the same thing

how can I get the property of the name of the button that I’m rolling over?  
getProperty(this,\_Name);  
also gives the name of the movieclip that they reside in, not the button.

(keeping in mind that these buttons are created with the duplicate clip function, so I cannot give them an instance name (or if I can I dont know how to)

thanks in advance

-Mopie

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 7, 2003, 8:08am UTC](https://forum.kirupa.com/t/duplicate-movie-clip-instance-naming/34869/4 "2003-11-07T08:08:41Z")

</div>

You use a dynamic event handler instead.

```auto
function place_btns() {
	duplicateMovieClip("btn", "btn"+growth, growth);
	this["btn"+growth]._x = btn_xpos;
	this["btn"+growth]._y = btn_ypos;
	this["btn"+growth].onRollOver = function() {
		trace(this._name);
	};
	btn_xpos += 10;
	if (btn_xpos>=105.5) {
		btn_ypos += 10;
		btn_xpos = 5.5;
	}
}

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 7, 2003, 3:42pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-instance-naming/34869/5 "2003-11-07T15:42:03Z")

</div>

thanks!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 7, 2003, 9:42pm UTC](https://forum.kirupa.com/t/duplicate-movie-clip-instance-naming/34869/6 "2003-11-07T21:42:57Z")

</div>

No problem. 😉
