InternalSetParent() private method

private InternalSetParent ( Container value ) : void
value Container
return void
示例#1
0
        /// <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");
            }
        }
示例#2
0
		/// <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");
			}
		}
示例#3
0
		public override void Dispose()
		{
			base.Dispose(); //Destroy GameObject tree first, avoid destroying each seperately;

			int numChildren = _children.Count;
			for (int i = numChildren - 1; i >= 0; --i)
			{
				DisplayObject obj = _children[i];
				obj.InternalSetParent(null); //Avoid RemoveParent call
				obj.Dispose();
			}
		}
示例#4
0
        /// <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.onAddedToStage.BroadcastCall();
                        }
                        else
                        {
                            child.onAddedToStage.Call();
                        }
                    }

                    InvalidateBatchingState(true);
                }
                return(child);
            }
            else
            {
                throw new Exception("Invalid child index");
            }
        }
示例#5
0
        /// <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._flags & Flags.Disposed) == 0)
                {
                    if (child is Container)
                    {
                        child.BroadcastEvent("onRemovedFromStage", null);
                        if (child == Stage.inst.focus || ((Container)child).IsAncestorOf(Stage.inst.focus))
                        {
                            Stage.inst._OnFocusRemoving(this);
                        }
                    }
                    else
                    {
                        child.DispatchEvent("onRemovedFromStage", null);
                        if (child == Stage.inst.focus)
                        {
                            Stage.inst._OnFocusRemoving(this);
                        }
                    }
                }
                _children.Remove(child);
                InvalidateBatchingState(true);
                if (!dispose)
                {
                    child.InternalSetParent(null);
                }
                else
                {
                    child.Dispose();
                }

                return(child);
            }
            else
            {
                throw new Exception("Invalid child index");
            }
        }
示例#6
0
        /// <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.onAddedToStage.BroadcastCall();
                        else
                            child.onAddedToStage.Call();
                    }

                    InvalidateBatchingState(true);
                }
                return child;
            }
            else
            {
                throw new Exception("Invalid child index");
            }
        }