# duplicateMovieClip

**URL:** <https://forum.kirupa.com/t/duplicatemovieclip/2631>\
**Category:** programming\
**Created:** [May 10, 2002, 12:15pm UTC](https://forum.kirupa.com/t/duplicatemovieclip/2631 "2002-05-10T12:15:58Z")\
**Posts on this page:** 8\
**Page:** 2

<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:** [May 13, 2002, 11:44pm UTC](https://forum.kirupa.com/t/duplicatemovieclip/2631/21 "2002-05-13T23:44:33Z")

</div>

Ou la la… I come back from vacation, and that’s what I see… Bread on the board, du pain sur la planche as we say…\r\rpom 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:** [May 15, 2002, 7:28am UTC](https://forum.kirupa.com/t/duplicatemovieclip/2631/22 "2002-05-15T07:28:04Z")

</div>

Hi once again!

That’s exactly what I want. But I don’t know where to put the code. I guess on the object (the circle) I want to duplicate. But is it onClipEvent (load), onClipEvent (enterFrame)? And do I have to put the settings, the function and the method there?

THX

Hartwig

---

<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:** [May 15, 2002, 4:46pm UTC](https://forum.kirupa.com/t/duplicatemovieclip/2631/23 "2002-05-15T16:46:48Z")

</div>

assuming that myCircle is in \_root, it can all go in frame 1. make sure to define the function before you call it, and don’t run the code more than once.

---

<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:** [May 16, 2002, 6:05am UTC](https://forum.kirupa.com/t/duplicatemovieclip/2631/24 "2002-05-16T06:05:26Z")

</div>

Hi!

Nothing tweens in my movie. Do you have a .fla which works. Could you send to [hartwig@fuerst.cc](mailto:hartwig@fuerst.cc).

THANKS THANKS THANKS THANKS THANKS

Hartwig

---

<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:** [May 17, 2002, 7:44pm UTC](https://forum.kirupa.com/t/duplicatemovieclip/2631/25 "2002-05-17T19:44:41Z")

</div>

here’s some code you can drop into frame 1 of an empty fla.

there’s a few modifications, a method for drawing circles has been added, and makeDemMovies() has been amended to remove the added movie after the duplication, and the duped layer is j+1 to avoid overwriting “myCircle”.

the circles aren’t really that great a shape, oh well … ; )

```auto
  
_root.settings = [
   {_x:300,_y:300,tweenSpd:5,tweenMax:150},
   {_x:200,_y:200,tweenSpd:10,tweenMax:200}
];

MovieClip.prototype.makeCircle= function(r){
   var c = this.createEmptyMovieClip("myCircle",0);
   with (c){
      lineStyle(0);
      moveTo(0,-r);
      curveTo(r,-r,r,0);
      curveTo(r,r,0,r);
      curveTo(-r,r,-r,0);
      curveTo(-r,-r,0,-r);
   }
}

function makeDemMovies() {
   _root.makeCircle(50);
   var j,mc;
   for(j in _root.settings){
      mc = _root.myCircle.duplicateMovieClip("dupedCircle"+j,j+1,_root.settings[j]);
      mc.onEnterFrame = mc.tween;
   }
   _root.myCircle.removeMovieClip();
}

MovieClip.prototype.tween = function(){
   if(this._xscale < this.tweenMax){
      this._xscale = this._yscale += this.tweenSpd;
   }else{
      this.onEnterFrame = null;
   }
}

makeDemMovies();

```

good luck!

---

<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:** [May 20, 2002, 11:58am UTC](https://forum.kirupa.com/t/duplicatemovieclip/2631/26 "2002-05-20T11:58:11Z")

</div>

Hi!

Where comes r from, the variable the function uses? And can’t I use an instance of a circle from my library called “myCircle” to be duplicated instead of using a method for drawing circles?

THX

Hartwig

---

<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:** [May 20, 2002, 8:24pm UTC](https://forum.kirupa.com/t/duplicatemovieclip/2631/27 "2002-05-20T20:24:04Z")

</div>

the r stands for radius (it could be named anything, r just makes sense), and it’s passed in the brackets when you call the function. in the above code i passed it 50.

yes, you can use any old movie clip you choose, i just wanted to have a 100% code based solution so it was a pure cut and paste.

if the movie is on the stage to begin with, you can just get rid of the part that creates the movie, and the part that deletes it later on. just make sure it’s named correctly.

if you want to attach the clip from your library, just change the part where the circle is created from the method i wrote, to a regular attachMovie call. you can delete it after or leave it on the stage, your call. same thing with the naming.

---

<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:** [May 22, 2002, 10:02am UTC](https://forum.kirupa.com/t/duplicatemovieclip/2631/28 "2002-05-22T10:02:03Z")

</div>

Hi!

It sounds so logical! But my circles aren’t duplicated. The debugger window only shows on instance and not more. I drew this instance by hand because I got an error with the with-loop which should draw the prototype-circle. This instance is called myCircle but isn’t duplicated. What am I making wrong. I dropped your cool code to frame one but it doesn’t work as we want.

???

Hartwig

[Previous page](https://forum.kirupa.com/t/duplicatemovieclip/2631.md?page=1)
