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 entered 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 ?

Answers


<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);

        }

Need Your Help

How to Save a Node

java save binary-tree

So I've been coding a basic binary Tree in Java and have run into a problem. The goal of this program is to "learn" new questions in order to guess an animal similar to 20 questions. However, I hav...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.