AS3 silent removechild: check if exist

sometimes you want to remove some children from the display list, but don’t know if the child exist or not!?

thanx to contains(), no probleme anymore;

[codesyntax lang="as3"]
if (this.contains(targetChild)) {
this.removeChild ( targetChild);
}
[/codesyntax]
another example
[codesyntax lang="as3"]
if (this.getChildByName(targetChild) != null) {
this.removeChild (this.getChildByName(targetChild));
}[/codesyntax]

Leave a Reply