开发者

How to add data to a spark list control dynamically

I have a spark list control(id="Cclist") in one of my custom components() and a text input control. When a value is en开发者_Python百科tered into the text input, I want to dynamically add the same into the list control. I tried doing the following :

protected function Cc_selectHandler(event:CustomEvent):void

{

 var cctext:DisplayObject = event.data as DisplayObject
 CcList.enabled = true;
 CcListButton.enabled = true;

 CcList.addChild(cctext);

}

But I get an error saying "addChild() is not available in this class. Instead, use addElement() or modify the skin". So I tried using addElement, but apparently that isnt available at all. Any idea what im doing wrong ?


<s:List x="732" y="299" width="191" height="108" id="lstQue">
<s:dataProvider>
    <mx:ArrayCollection>

    </mx:ArrayCollection>
</s:dataProvider>

Needs a dataProvider to use the addItem method. A quick and dirty way is just to add a blank dataProvider with a blank ArrayCollection enclosed.

Example of adding to it through a click event.

protected function imgAddToList_clickHandler(event:MouseEvent):void
        {
                            this.lstQue.dataProvider.addItem(DataGrid.selectedItem.fldVideoThumb);

        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜