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);
}
精彩评论