Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 如何更改Flex ArrayCollection中项目的值_Apache Flex_Actionscript 3_Arraycollection - Fatal编程技术网

Apache flex 如何更改Flex ArrayCollection中项目的值

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

我有一个具有预定义值的ArrayCollection。我想为arrayCollection中的项分配一个新值,但无法确定如何分配。基本上我想做这样的事情:acGuages.itemUpdated(0);(将值从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;

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

acGuages.itemUpdated(0).thevalue = 90;
可以重写为:

acGuages[0].thevalue = 90;

而且一切都应该按预期进行。

太好了,谢谢。我还更新了它,以便在初始化函数中设置它。公共函数int():void{acGuages[0]。thevalue=90;acGuages.refresh();}很高兴它能工作:)仅供参考,您可能不需要在init函数中调用refresh()。如果内存正常,则只有在应用筛选器或排序时才需要refresh()。