(Flex SDK4)关于BorderContainer 的addChild/addElement 问题

flex中 addChild添加不能用
addChild只能添加UI组件,所以Sprite不能添加。
解决方法:
方法1.  var mySprite:Sprite = new Sprite();       
    mySprite.x=0;
    mySprite.y=0;
    mySprite.graphics.beginFill(0xFFCC00);
    mySprite.graphics.drawCircle( 40, 40, 40 );
 var ui:UIComponent=new UIComponent();//创建一个组件,把
    ui.addChild(mySprite);
    bc.addChild(ui);
方法2:
   bc.rawChildren.addChild(ui);
flex 4中,addChild 总是不能显示。
解决:
The following table shows these properties and methods:

Spark container

MX container

Description

numElements

numChildren

Number of children the container.

addElement()

addChild()

Adds a child to the container as the last child.

addElementAt()

addChildAt()

Add a child at a specific index in the container.

 

getChildren()

Returns an Array containing all children.

getElementAt()

getChildAt()

Return a child at the specified index.

 

getChildByName()

Return a child with the specified id.

getElementIndex()

 

Returns the index of a child.

removeAllElements()

removeAllChildren()

Removes all container children.

removeElement()

removeChild()

Remove the first child.

removeElementAt()

removeChildAt()

Remove the child at the specified index

setElementIndex()

setChildIndex()

Set the index of a child.

swapElements()

swapChildren()

Swap the indexes of two children

swapElementsAt()

swapChildrenAt()

Swap the indexes of two children.

Spark用addElement,MX用addChild
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
应该就是这个来区分MX还是Spark吧
posted @ 2010-09-11 23:13  陈同学  阅读(2052)  评论(0)    收藏  举报