# duplicateMovieClip help

**URL:** <https://forum.kirupa.com/t/duplicatemovieclip-help/186957>\
**Category:** Uncategorized\
**Created:** [April 25, 2006, 4:07pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-help/186957 "2006-04-25T16:07:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![artistwantab](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@artistwantab](https://forum.kirupa.com/u/artistwantab)\
**Post date:** [April 25, 2006, 4:07pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-help/186957/1 "2006-04-25T16:07:28Z")

</div>

My code is below.

I am having some difficulty getting the duplicateMovieClip to work here. I can easily attach the movie within the “for” statement and get the result I want but I have multiple MC’s that I want to use this function on and alot of the code would be redundent. Is there better way?

```auto
for (i = 0; i < 1; i++) {
 var myMC = this.attachMovie ("dragger", "dragger" + i, i);
 this._x = 400;
 this._y = 300;
 this.onEnterFrame = explode;
}
function explode () {
 for (i = 0; i < 50; i++) {
  //var explode = this.attachMovie ("dragger", "dragger" + i, i);
  //explode._x = 400;
  //explode._y = 300;
  var rn = Math.floor (Math.random () * (300 - 25)) + 250;
  this._xscale = rn;
  this._yscale = rn;
  this.dx = Math.round (Math.random () * 600);
  this.dy = Math.round (Math.random () * 600);
  this.speed = Math.floor (Math.random () * (50 - 10)) + 10;
  this.duplicateMovieClip (this, this.getNextHighestDepth ());
  this.onEnterFrame = explosion;
 }
}
function explosion () {
 this._x += (this.dx - this._x) / this.speed;
 this._y += (this.dy - this._y) / this.speed;
}

```

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [April 25, 2006, 4:12pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-help/186957/2 "2006-04-25T16:12:42Z")

</div>

That code looks like it would crash a computer awefull quick. A loop making objects and onEnterFrame of those objects, you are running another loop, which attaches objects and duplicates them. Also animating them all at the same time.

wow.

---

<div class="post-metadata">

**Author:** ![artistwantab](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@artistwantab](https://forum.kirupa.com/u/artistwantab)\
**Post date:** [April 25, 2006, 4:26pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-help/186957/3 "2006-04-25T16:26:15Z")

</div>

> [@Defective](#):
>
> That code looks like it would crash a computer awefull quick. A loop making objects and onEnterFrame of those objects, you are running another loop, which attaches objects and duplicates them. Also animating them all at the same time.
> 
> wow.

I am not having ANY problems but…

the demographic that will be going to my site wont be on great computers.

Thank you…You just saved me alot of headaches.

What do you recommend?

Please don’t say Custom MC Class I am avoiding learning how to do that. 😛

---

<div class="post-metadata">

**Author:** ![artistwantab](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@artistwantab](https://forum.kirupa.com/u/artistwantab)\
**Post date:** [April 25, 2006, 4:28pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-help/186957/4 "2006-04-25T16:28:52Z")

</div>

What do you recommend? I only want to bring in ONE object and duplicate it and animate all the instances.

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [April 25, 2006, 4:34pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-help/186957/5 "2006-04-25T16:34:40Z")

</div>

i dont really understand from the code what you are trying to accomplish, give me a bit of an explaination:)

---

<div class="post-metadata">

**Author:** ![MichaelxxOA](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@MichaelxxOA](https://forum.kirupa.com/u/MichaelxxOA)\
**Post date:** [April 25, 2006, 4:38pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-help/186957/6 "2006-04-25T16:38:08Z")

</div>

```auto
this.duplicateMovieClip (this, this.getNextHighestDepth ());

```

should be something similar too.

```auto
this.duplicateMovieClip (this, NEWNAME, this.getNextHighestDepth ());

```

Amongst quite a few other things… I will initially give you this one… you are not utilizing the duplicateMovieClip method correctly.

TakeCare  
\_Michael

---

<div class="post-metadata">

**Author:** ![artistwantab](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@artistwantab](https://forum.kirupa.com/u/artistwantab)\
**Post date:** [April 25, 2006, 4:38pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-help/186957/7 "2006-04-25T16:38:33Z")

</div>

> [@Defective](#):
>
> i dont really understand from the code what you are trying to accomplish, give me a bit of an explaination:)

The following code works fine. But instead of using the attachMovie within the For loop. I want use duplicateMovieClip. Then I can attach the object and call the function for the object.

```auto
 
for (i = 0; i < 25; i++) {
 var explode = this.attachMovie ("dragger", "dragger" + i, i);
 explode._x = 400;
 explode._y = 300;
 var rn = Math.floor (Math.random () * (300 - 25)) + 250;
 explode._xscale = rn;
 explode._yscale = rn;
 explode.dx = Math.round (Math.random () * 600);
 explode.dy = Math.round (Math.random () * 600);
 explode.speed = Math.floor (Math.random () * (50 - 10)) + 10;
 explode.onEnterFrame = explosion;
}
function explosion () {
 this._x += (this.dx - this._x) / this.speed;
 this._y += (this.dy - this._y) / this.speed;
}

```

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [April 25, 2006, 4:39pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-help/186957/8 "2006-04-25T16:39:06Z")

</div>

yeah, i noticed he was trying to dupe with attach syntax.🙂

---

<div class="post-metadata">

**Author:** ![artistwantab](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@artistwantab](https://forum.kirupa.com/u/artistwantab)\
**Post date:** [April 25, 2006, 4:44pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-help/186957/9 "2006-04-25T16:44:14Z")

</div>

> [@MichaelxxOA](#):
>
> Amongst quite a few other things… I

Whenever you have time I would love to hear it. Any help is welcome.

---

<div class="post-metadata">

**Author:** ![artistwantab](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@artistwantab](https://forum.kirupa.com/u/artistwantab)\
**Post date:** [April 25, 2006, 9:50pm UTC](https://forum.kirupa.com/t/duplicatemovieclip-help/186957/10 "2006-04-25T21:50:10Z")

</div>

Anyone?
