Sunday, February 6, 2011

Useful displayObject Utilities

// remove any displayObject, irrespective of location (remove a parent from the child etc)
function kill(object:*):void {
if(object.parent != null){
var parent:DisplayObjectContainer = object.parent;
parent.removeChild(object);
}
}

// remove all contents of a target MovieClip
function burn(target:MovieClip):void {
while (target.numChildren) target.removeChildAt(0);
}

No comments: