Dupplicate a MovieClip and its Content

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

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.

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!

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… :-\

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

I made it! Phew… :slight_smile:

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…