如何动态地将数据添加到 Spark 列表控件

发布于 2024-10-05 13:17:22 字数 460 浏览 0 评论 0原文

我的自定义组件之一中有一个火花列表控件(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

¢蛋碎的人ぎ生 2024-10-12 13:17:23
<s:List x="732" y="299" width="191" height="108" id="lstQue">
<s:dataProvider>
    <mx:ArrayCollection>

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

需要一个 dataProvider 才能使用 addItem 方法。一种快速而肮脏的方法是添加一个空白的 dataProvider,其中包含一个空白的 ArrayCollection。

通过点击事件添加的示例。

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

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

        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文