PDA

View Full Version : Duplicating movie clips as3


samWhisker
12-29-2008, 01:37 PM
I have done a lot of reading on this subject and of course support is weak. i have tried oh so many things and the closest i have come is the class by senocular.

This works as a class perfectly, however if you try and duplicate a movie clip that has nested children they do not copy accross just the parent. let me explain

import duplicateDisplayObject;

//i create a holder for my duplicateed movie clip
var mHolder:MovieClip = new MovieClip();
addChild(mHolder);

// i add lots of different movies to it
var m1 = new mcBg1();
mHolder.addChild(m);
var m2 = new mcBg2();
mHolder.addChild(m);
var m3 = new mcBg3();
mHolder.addChild(m);

// use the class here to copy 'mHolder' the parent of the movie clip 'm'
var newInstance:DisplayObject=duplicateDisplayObject(m Holder,true);
newInstance.x=200;// shift to see duplicate

trace(newInstance.width)

So the result of this i guess is mHolder been duplicated and not the movie/movies attached. does anyone have a theory on this?

cheers guys:cool:

palmjack
12-29-2008, 01:44 PM
I think the problem is that DisplayObject isn't the same as DisplayObjectContainer - which is your holder movie clip.

samWhisker
12-29-2008, 01:59 PM
hi thanks

er the holder movie clip is mHolder, this gets created dynamically on a mouse down, so mHolder needs duplicating along with the drawings attached to it

is that what you meant?

palmjack
12-29-2008, 02:36 PM
No, I meant that DiplayObject can't have any children and DisplayObjectContainer can. I'm not sure about this class, haven't used it.

samWhisker
01-07-2009, 12:38 PM
Does anyone know this class by senocular. and how i could customize it to copy the display object container??

Thanks