如何更改Flex ArrayCollection中项目的值(How do I change the value of an item in a Flex ArrayCollection)

编程入门 行业动态 更新时间:2024-10-16 02:25:29
如何更改Flex ArrayCollection中项目的值(How do I change the value of an item in a Flex ArrayCollection)

我有一个预定义值的ArrayCollection。 我想为arrayCollection中的项目分配一个新值,但无法弄清楚如何。 基本上我想要做这样的事情:acGuages.itemUpdated(0).thevalue = 90; (将值从25更改为90)。 谢谢。

private var arrayGuages:Array=[ {thevalue:"25",height:"115"}, {thevalue:"45",height:"115"}, {thevalue:"15",height:"115"}, {thevalue:"95",height:"115"}, ]; [Bindable] public var acGuages:ArrayCollection=new ArrayCollection(arrayGuages); acGuages.itemUpdated(0).thevalue = 90;

I have an ArrayCollection with values predefined. I want to assign a new value to items in the arrayCollection but can not figure out how. Basically I want to do something like this: acGuages.itemUpdated(0).thevalue = 90; (Changing the value from 25 to 90). Thanks.

private var arrayGuages:Array=[ {thevalue:"25",height:"115"}, {thevalue:"45",height:"115"}, {thevalue:"15",height:"115"}, {thevalue:"95",height:"115"}, ]; [Bindable] public var acGuages:ArrayCollection=new ArrayCollection(arrayGuages); acGuages.itemUpdated(0).thevalue = 90;

最满意答案

ArrayCollection支持随机访问其元素,就像Array一样。 换句话说,你的路线:

acGuages.itemUpdated(0).thevalue = 90;

可以改写为:

acGuages[0].thevalue = 90;

它应该都按预期工作。

ArrayCollection supports random access to its elements, just like Array. In other words, your line:

acGuages.itemUpdated(0).thevalue = 90;

Can be rewritten as:

acGuages[0].thevalue = 90;

And it should all work as expected.

更多推荐

本文发布于:2023-07-14 14:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1105130.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何更改   项目   Flex   ArrayCollection   change

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!