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;
}
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;
}