質問

値が事前に定義された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;
役に立ちましたか?

解決

ArrayCollectionは、Arrayと同様に、要素へのランダムアクセスをサポートしています。言い換えれば、あなたの行:

acGuages.itemUpdated(0).thevalue = 90;

次のように書き換え可能:

acGuages[0].thevalue = 90;

そして、期待通りに動作するはずです。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top