Quick and dirty solution to duplicate a DisplayObject in Flash, check the duplicate flex component snippet to get a more elegant soltuion.
function duplicateDisplayObject(target:DisplayObject):DisplayObject {
// create duplicate
var targetClass:Class = Object(target).constructor;
var duplicate:DisplayObject = new targetClass();
// duplicate transformation properties
duplicate.transform = target.transform;
duplicate.filters = target.filters;
duplicate.cacheAsBitmap = target.cacheAsBitmap;
duplicate.opaqueBackground = target.opaqueBackground;
// Check the scale9
if (target.scale9Grid) {
var rectangle:Rectangle = target.scale9Grid;
duplicate.scale9Grid = rectangle;
}
return duplicate;
}

