如何动态地将数据添加到 Spark 列表控件
我的自定义组件之一中有一个火花列表控件(id =“Cclist”)和一个文本输入控件。当在文本输入中输入值时,我想将其动态添加到列表控件中。我尝试执行以下操作:
protected function Cc_selectHandler(event:CustomEvent):void
{
var cctext:DisplayObject = event.data as DisplayObject
CcList.enabled = true;
CcListButton.enabled = true;
CcList.addChild(cctext);
}
但出现错误,提示“addChild() 在此类中不可用。相反,请使用 addElement() 或修改外观”。所以我尝试使用 addElement,但显然根本不可用。知道我做错了什么吗?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
需要一个 dataProvider 才能使用 addItem 方法。一种快速而肮脏的方法是添加一个空白的 dataProvider,其中包含一个空白的 ArrayCollection。
通过点击事件添加的示例。
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.