# Dupplicate a MovieClip and its Content

**URL:** <https://forum.kirupa.com/t/dupplicate-a-movieclip-and-its-content/7724>\
**Category:** flash\
**Created:** [November 6, 2002, 2:42pm UTC](https://forum.kirupa.com/t/dupplicate-a-movieclip-and-its-content/7724 "2002-11-06T14:42:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisgfx](https://avatars.discourse-cdn.com/v4/letter/c/ed8c4c/32.png) [@chrisgfx](https://forum.kirupa.com/u/chrisgfx)\
**Post date:** [November 6, 2002, 2:42pm UTC](https://forum.kirupa.com/t/dupplicate-a-movieclip-and-its-content/7724/1 "2002-11-06T14:42:36Z")

</div>

I wonder if there’s a way to duplicate a MovieClip created dynamicaly and its content.

For example:

* * *

this.createEmptyMovieClip(“Photo”, 1);

Photo.loadMovie(“image.jpg”);

Photo.duplicateMovieClip(“Photo2”, 2);

* * *

This code does not duplicate the content but only an empty MovieClip.  
But it works if instead of creating the empty MovieClip Photo, i create it by the hand in Flash and put the image in it.

Can someone tell me if it’s possible to do that in actionscript?

Thank you in advance,  
Christophe

---

<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 6, 2002, 4:58pm UTC](https://forum.kirupa.com/t/dupplicate-a-movieclip-and-its-content/7724/2 "2002-11-06T16:58:35Z")

</div>

hi,

Do u want several MCs with the same image on them?  
Because if that’s the case u could do the duplications and  
load (or attach) the imaage onto all of them with a ‘for’ loop.

```auto
MaxOfPhotos = 2;
this.createEmptyMovieClip("Photo1", 1);
Photo1.duplicateMovieClip("Photo2", 2);
for (var i = 0; i < MaxOfPhotos; i++) {
	theMovieClip = eval("Photo"+i);
	theMovieClip.loadMovie("image.jpg");
}

```

Cheers

SHO

Ps.: haven’t tested it!

---

<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, 2002, 4:57am UTC](https://forum.kirupa.com/t/dupplicate-a-movieclip-and-its-content/7724/3 "2002-11-07T04:57:43Z")

</div>

But if you do that, does each clip load its own version of the picture or do they load it once for all. Because if they all load the picture… :-\

---

<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, 2002, 9:14am UTC](https://forum.kirupa.com/t/dupplicate-a-movieclip-and-its-content/7724/4 "2002-11-07T09:14:21Z")

</div>

Yes, i agree with you ilyaslamasse.

What i try to do is a “simple” cross-fading transition between two image in two MovieClip.  
So what i think at first was to duplicate the original MovieClip and put the new one behind it. And then i can change the \_alpha to make the cross-fading from the old image to the new one.

Now i’m trying to make the effects in a different way:  
I have two MovieClips. I swap their \_Level of Depth before  
loading the new image in the MovieClip at the top of the other.

for the moment, i have that code:

* * *

//initialization  
photo\_nb = 0;

* * *

## //code on a button(this in the code) if (cible == Photo1 && this.nb != photo\_nb) { trace(Photo1.\_alpha); trace(Photo1.\_level); cible = \_root[“Photo2”]; Photo2.\_alpha = 0; Photo2.swapDepths(cible); trace(Photo1.\_alpha); trace(Photo1.\_level); pic = “images/clio\_0” + this.nb + “.jpg”; cible.loadMovie(pic); photo\_nb = this.nb; } else if (cible == Photo2 && this.nb != photo\_nb) { trace(Photo2.\_alpha); cible = \_root[“Photo1”]; Photo1.\_alpha = 0; Photo1.swapDepths(cible); trace(Photo2.\_alpha); pic = “images/clio\_0” + this.nb + “.jpg”; cible.loadMovie(pic); photo\_nb = this.nb; }

This code doesn’t make the swapDepths now because i need  
to change the (cible) to a number.

Thanks for the comments,  
Christophe

---

<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, 2002, 10:00am UTC](https://forum.kirupa.com/t/dupplicate-a-movieclip-and-its-content/7724/5 "2002-11-07T10:00:26Z")

</div>

I made it! Phew… 🙂

## Here is the new code for the button:

## function Release() { if (cible == Photo1 && this.nb != photo\_nb) { cible = \_root[“Photo2”]; Photo2.\_alpha = 0; Photo2.swapDepths(Photo1); } else if (cible == Photo2 && this.nb != photo\_nb) { cible = \_root[“Photo1”]; Photo1.\_alpha = 0; Photo1.swapDepths(Photo2); } pic = “images/clio\_0” + this.nb + “.jpg”; cible.loadMovie(pic); photo\_nb = this.nb; }

I can give explanations for the one who don’t understand some variables…
