views:

211

answers:

0

code looks like:

<fx:Script>
    <![CDATA[
        private var role:DisplayObject;
        protected function btnAdd_clickHandler(event:MouseEvent):void
        {

            for(var i:int=0;i<10;i++){

                var dis:DisplayObject = this.main.addChild(this.role);

                dis.x = i+10;
                dis.y = 400;
            }
        }

    ]]>
</fx:Script>
<s:SpriteVisualElement id="main" width="100%" height="100%"/>


<custom:Button x="724" y="10" id="btnAdd" label="addRole" click="btnAdd_clickHandler(event)"/>

I want to add 10 roles on the SpriteVisualElement but this dis object always the same, how can I control them..

I looked into the code of addChild

//--------------------------------------------------------------------------
//
//  Overridden methods
//
//--------------------------------------------------------------------------

/**
 *  @private
 */
override public function addChild(child:DisplayObject):DisplayObject
{
    // Do anything that needs to be done before the child is added.
    // In the case of SVE..we just need to deal with text UIComponents
    // and setting them up because this is a "static" object
    addingChild(child);

    super.addChild(child);

    childAdded(child);

    return child;
}

they return the objec I pass to it !

so how could I get the real object that added to the displaylist, or I can only add different sprite to the SpriteVisualElement?