# Duplicate instances (talking to)

**URL:** <https://forum.kirupa.com/t/duplicate-instances-talking-to/17302>\
**Category:** flash\
**Created:** [April 3, 2003, 3:53pm UTC](https://forum.kirupa.com/t/duplicate-instances-talking-to/17302 "2003-04-03T15:53:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![guitarzen](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@guitarzen](https://forum.kirupa.com/u/guitarzen)\
**Post date:** [April 3, 2003, 3:53pm UTC](https://forum.kirupa.com/t/duplicate-instances-talking-to/17302/1 "2003-04-03T15:53:13Z")

</div>

If you duplicate a movie clip with say the name “ball” you end up with ball1, ball2, ball3, etc., on level0.

If I want to call out an instance in my main movie that is duplicated how can I achieve this?

Anyone?

---

<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:** [April 3, 2003, 4:23pm UTC](https://forum.kirupa.com/t/duplicate-instances-talking-to/17302/2 "2003-04-03T16:23:04Z")

</div>

um… dunno if that’s what you mean but try it:

created mc named ball1, ball2, ball3,…,ballN

```auto

for (j=1; j!=N;j++) _root["ball"+j].onEnterFrame = function() {
this._y += 5;
}

```

dunno if it even works…

---

<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:** [April 3, 2003, 4:48pm UTC](https://forum.kirupa.com/t/duplicate-instances-talking-to/17302/3 "2003-04-03T16:48:52Z")

</div>

yeah, that code should work. basically, you’d access an instance like you’d access any other, by its name. if you created the instances dynamically, it’s always possible to access each instance you created.

for example:

```auto

onClipEvent(load) {
for (i = 0; i < 10; ++i) {
this.duplicateMovieClip("ball"+i, i);
}
}
onClipEvent(enterFrame) {
for (i = 0; i < 10; ++i) {
mc = _root["ball"+i];
with(mc) {
++_x;
--_y;
}
}
}

```

notice that i used \_root[“ball”+i] up there. when you dynamically access an instance you can’t simply say:  
“ball”+i.\_x = 250;

flash will give you an error or two. rather you’d direct where the actual instance is, which in the example, is in \_root. you can also use \_parent or another movieclip:  
main\_ball[“ball”+i];

let me know if you’re still confused.

---

<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:** [April 3, 2003, 5:16pm UTC](https://forum.kirupa.com/t/duplicate-instances-talking-to/17302/4 "2003-04-03T17:16:33Z")

</div>

Well I may have not made my problem clear. I have the duplicate movie thing down. My problem is that there is an instance on the button I am duplicating that is called out to change its color. However, when it is duplicated and you get ball1, ball2 and ball3 etc., I cannot reach that instance anymore.

here is my duplicate code and I also attached the test movie. The colored button is what I am trying to reference the instance in the duplicated buttons.

on (press) {  
num = 10;  
xstart = -25;  
n = 1;  
while (n \<= num) {  
duplicateMovieClip(“testy”, “ball” add n, n);  
setProperty(“ball” add n, \_x, xstart + n\*35);  
n = n + 1;  
}  
setProperty(“testy”, \_visible, 0);  
}

---

<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:** [April 3, 2003, 9:21pm UTC](https://forum.kirupa.com/t/duplicate-instances-talking-to/17302/5 "2003-04-03T21:21:14Z")

</div>

hm…i looked at your code and i don’t know if this will help, but it looks like you duplicate those buttons on the same depth. you can only have one created instance per layer or the new one replaces the one currently in that layer.
