打印

[AS3] addChild 和addChildAt

addChild 和addChildAt 这2个到底有什么区别,到底是本质上的区别还是用法上的区别
还有 var 和 const 有什么区别
复制内容到剪贴板
代码:
addChild(child:DisplayObject)
将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。 子项将被添加到该 DisplayObjectContainer 实例中其它所有子项的前(上)面。 (要将某子项添加到特定索引位置,请使用 addChildAt() 方法。)

[ 本帖最后由 aglice 于 2008-9-3 12:35 编辑 ]
复制内容到剪贴板
代码:
addChildAt(child:DisplayObject, index:int)

TOP

还在为头像烦恼?还在为不能关注好友动态烦忧?快来蓝色理想家园吧!
不理解楼主的意思,const是指定义常量,var是审请变量,它们的区别还要特别指明?

TOP

/**
     *  Adds a child DisplayObject to this Container.
     *  The child is added after other existing children,
     *  so that the first child added has index 0,
     *  the next has index 1, an so on.
     *
     *  <p><b>Note: </b>While the <code>child</code> argument to the method
     *  is specified as of type DisplayObject, the argument must implement
     *  the IUIComponent interface to be added as a child of a container.
     *  All Flex components implement this interface.</p>
     *
     *  <p>Children are layered from back to front.
     *  In other words, if children overlap, the one with index 0
     *  is farthest to the back, and the one with index
     *  <code>numChildren - 1</code> is frontmost.
     *  This means the newly added children are layered
     *  in front of existing children.</p>
     *
     *  @param child The DisplayObject to add as a child of this Container.
     *  It must implement the IUIComponent interface.
     *
     *  @return The added child as an object of type DisplayObject.
     *  You typically cast the return value to UIComponent,
     *  or to the type of the added component.
     *
     *  @see mx.core.IUIComponent
     *
     *  @tiptext Adds a child object to this container.
     */
    override public function addChild(child:DisplayObject):DisplayObject
    {
        return addChildAt(child, numChildren);

        /*
        addingChild(child);

        if (contentPane)
            contentPane.addChild(child);
        else
            $addChild(child);

        childAdded(child);

        return child;
        */
    }
努力工作中...

TOP

const是声明常量的通常是有值的~~~
var是审请变

TOP

建议楼主,还是看一下AS3基础吧

TOP