/// <summary>
///
/// </summary>
/// <param name="index"></param>
/// <param name="dispose"></param>
/// <returns></returns>
public DisplayObject RemoveChildAt(int index, bool dispose)
{
if (index >= 0 && index < _children.Count)
{
DisplayObject child = _children[index];
if (stage != null && !child._disposed)
{
if (child is Container)
{
child.BroadcastEvent("onRemovedFromStage", null);
}
else
{
child.DispatchEvent("onRemovedFromStage", null);
}
}
_children.Remove(child);
InvalidateBatchingState(true);
if (!dispose)
{
child.InternalSetParent(null);
}
else
{
child.Dispose();
}
return(child);
}
else
{
throw new Exception("Invalid child index");
}
}