Apache flex 如何更改Flex ArrayCollection中项目的值
我有一个具有预定义值的ArrayCollection。我想为arrayCollection中的项分配一个新值,但无法确定如何分配。基本上我想做这样的事情:acGuages.itemUpdated(0);(将值从25更改为90)。谢谢Apache flex 如何更改Flex ArrayCollection中项目的值,apache-flex,actionscript-3,arraycollection,Apache Flex,Actionscript 3,Arraycollection,我有一个具有预定义值的ArrayCollection。我想为arrayCollection中的项分配一个新值,但无法确定如何分配。基本上我想做这样的事情:acGuages.itemUpdated(0);(将值从25更改为90)。谢谢 private var arrayGuages:Array=[ {thevalue:"25",height:"115"}, {thevalue:"45",height:"115"}, {thevalue:"15
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;
而且一切都应该按预期进行。太好了,谢谢。我还更新了它,以便在初始化函数中设置它。公共函数int():void{acGuages[0]。thevalue=90;acGuages.refresh();}很高兴它能工作:)仅供参考,您可能不需要在init函数中调用refresh()。如果内存正常,则只有在应用筛选器或排序时才需要refresh()。