/// <summary> /// /// </summary> /// <param name="child"></param> /// <param name="index"></param> /// <returns></returns> public DisplayObject AddChildAt(DisplayObject child, int index) { int count = _children.Count; if (index >= 0 && index <= count) { if (child.parent == this) { SetChildIndex(child, index); } else { child.RemoveFromParent(); if (index == count) _children.Add(child); else _children.Insert(index, child); child.InternalSetParent(this); if (stage != null) { if (child is Container) child.BroadcastEvent("onAddedToStage", null); else child.DispatchEvent("onAddedToStage", null); } } return child; } else { throw new Exception("Invalid child index"); } }
static public int RemoveFromParent(IntPtr l) { try { FairyGUI.DisplayObject self = (FairyGUI.DisplayObject)checkSelf(l); self.RemoveFromParent(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public DisplayObject AddChildAt(DisplayObject child, int index) { int count = _children.Count; if (index >= 0 && index <= count) { if (child.parent == this) { SetChildIndex(child, index); } else { child.RemoveFromParent(); if (index == count) { _children.Add(child); } else { _children.Insert(index, child); } child.SetParent(this); child.tmpZ = 0; if (stage != null) { if (child is Container) { child.onAddedToStage.BroadcastCall(); } else { child.onAddedToStage.Call(); } } InvalidateBatchingState(); } return(child); } else { throw new Exception("Invalid child index"); } }
public DisplayObject AddChildAt(DisplayObject child, int index) { int count = _children.Count; if (index >= 0 && index <= count) { if (child.parent == this) { SetChildIndex(child, index); } else { child.RemoveFromParent(); if (index == count) _children.Add(child); else _children.Insert(index, child); child.SetParent(this); if (stage != null) { if (child is Container) child.onAddedToStage.BroadcastCall(); else child.onAddedToStage.Call(); } InvalidateBatchingState(true); } return child; } else { throw new Exception("Invalid child index"); } }