public virtual AsDisplayObject removeChildAt(int index, bool dispose) { if (index >= 0 && index < getNumChildren()) { AsDisplayObject child = mChildren[index]; child.dispatchEventWith(AsEvent.REMOVED, true); if (getStage() != null) { AsDisplayObjectContainer container = child as AsDisplayObjectContainer; if (container != null) { container.broadcastEventWith(AsEvent.REMOVED_FROM_STAGE); } else { child.dispatchEventWith(AsEvent.REMOVED_FROM_STAGE); } } child.setParent(null); index = mChildren.indexOf(child); if (index >= 0) { mChildren.splice(index, (uint)(1)); } if (dispose) { child.dispose(); } return(child); } else { throw new AsRangeError("Invalid child index"); } }
public virtual AsDisplayObject addChildAt(AsDisplayObject child, int index) { int numChildren = (int)(mChildren.getLength()); if(index >= 0 && index <= numChildren) { child.removeFromParent(); if(index == numChildren) { mChildren.push(child); } else { mChildren.splice(index, (uint)(0), child); } child.setParent(this); child.dispatchEventWith(AsEvent.ADDED, true); if(getStage() != null) { AsDisplayObjectContainer container = child as AsDisplayObjectContainer; if(container != null) { container.broadcastEventWith(AsEvent.ADDED_TO_STAGE); } else { child.dispatchEventWith(AsEvent.ADDED_TO_STAGE); } } return child; } else { throw new AsRangeError("Invalid child index"); } }
public virtual AsDisplayObject addChildAt(AsDisplayObject child, int index) { int numChildren = (int)(mChildren.getLength()); if (index >= 0 && index <= numChildren) { child.removeFromParent(); if (index == numChildren) { mChildren.push(child); } else { mChildren.splice(index, (uint)(0), child); } child.setParent(this); child.dispatchEventWith(AsEvent.ADDED, true); if (getStage() != null) { AsDisplayObjectContainer container = child as AsDisplayObjectContainer; if (container != null) { container.broadcastEventWith(AsEvent.ADDED_TO_STAGE); } else { child.dispatchEventWith(AsEvent.ADDED_TO_STAGE); } } return(child); } else { throw new AsRangeError("Invalid child index"); } }