PDA

View Full Version : Duplicate problem


lucas_wallsi
11-11-2007, 07:35 AM
HI there,

I am trying to use this code to duplicate a movieclip....i am passing it into this function. Its not my code was posted on kirupa i think.

Anyway I get nothing when the function runs, the variable duplicate is not a duplicate of the movieclip i have passed in. ANyone know why?

Thanks for your time,

Nathan


public function duplicateDisplayObject(target:DisplayObject, autoAdd:Boolean):DisplayObject
{
// create duplicate
var targetClass:Class = Object(target).constructor;
var duplicate:DisplayObject = new targetClass();

// duplicate properties
duplicate.transform = target.transform;
duplicate.filters = target.filters;
duplicate.cacheAsBitmap = target.cacheAsBitmap;
duplicate.opaqueBackground = target.opaqueBackground;

// add to target parent's display list
// if autoAdd was provided as true
if (autoAdd && target.parent)
{
target.parent.addChild(duplicate);
}
return duplicate;
}

xfreece
11-12-2007, 05:55 AM
I just have a thought. I can't see how you can duplicate an object since all instances are independet depending on how the code influenced on the specific instance.

But as I said, just a thought.