PDA

View Full Version : duplicateMovieClip on MC's containing dyn. generated MC's



stryke
May 15th, 2005, 12:19 PM
Hi there

I have a movie clip that contains many many dynamically generated mc's that have also some dynamically generated mc's in them :glasses:
Now i wanna duplicate that large MC .... and of course that does not work cause it will not copy all those small MC's that are contained. If I duplicate all the MC's contained this also will not work. cause they contain generated MC's and so on :crazy:

Okay enough blabla: Is there a possibility to duplicate the big MC containing all the small MC's ???

I know Flash can't do it but is there a way around it?

I had one idea of keeping an array of all the generated mc's in my MC class. This works fine but when i duplicate one contained MC i wont get it into the duplication target, it will always be inside his _parent movieclip :(

Uhff... this really seems kinda complicated hope somebody can understand ;)

EmeniusXp
May 15th, 2005, 04:47 PM
Try using the original MC as initObj when you duplicateMovieClip. Maybe that does the trick.

stryke
May 15th, 2005, 05:30 PM
Try using the original MC as initObj when you duplicateMovieClip. Maybe that does the trick.

Seems like that does not work :(

I think the main problem really is duplicating a movieclip into another movieclip. Because if u begin to duplicate everything inside the main movieclip all the new children mc's will remain in the main mc and not in another one (as I want to duplicate the main mc too...)

scotty
May 15th, 2005, 06:08 PM
Maybe this will help (put the code in frame 1)


stop();
for (var i = 0; i<2; i++) {
var main_mc = this.createEmptyMovieClip("main"+i, i);
main_mc._x = 50+i*300;
main_mc._y = 50;
drawClip(main_mc, 225, 400);
for (var j = 0; j<8; j++) {
var sub_mc = main_mc.createEmptyMovieClip("sub"+j, j);
sub_mc._x = 50+(j%2)*75;
sub_mc._y = 50+Math.floor(j/2)*75;
drawClip(sub_mc, 50, 50);
}
}
function drawClip(clip, w, h) {
clip.lineStyle(1, 0xCCCCCC);
clip.moveTo(0, 0);
clip.lineTo(w, 0);
clip.lineTo(w, h);
clip.lineTo(0, h);
clip.lineTo(0, 0);
}

scotty(-:

stryke
May 16th, 2005, 03:57 AM
Hey thanx for the code. I realize you simply draw your content 2 times, so that you have no need to duplicate stuff. Maybe I can do that the same way but i have to test it first for performance issues. Because drawing all those shapes (it is a map) even only one time did cost so much cpu i had to distribute the drawing process over multiple frames ... and i now need 4 duplicates of the map :pa:
But all in all it is a very good suggestion I did not really think about. thanx alot :)

scotty
May 16th, 2005, 04:45 AM
welcome =)

The code I gave was just to give you an idea ;)

scotty(-:

stryke
May 16th, 2005, 05:18 AM
welcome =)

The code I gave was just to give you an idea ;)

scotty(-:

It works :)

Thank u very much