Manipulating ArrayCollection

Manipulating Flex ArrayCollection

This shows you how to manipulate flex data structure called ArrayCollection.

Assuming that you have the following data

[Bindable]
private var medalsAC:ArrayCollection = new ArrayCollection( [
{ Country: "USA", Gold: 35, Silver:39, Bronze: 29 },
{ Country: "China", Gold: 32, Silver:17, Bronze: 14 },
{ Country: "Russia", Gold: 27, Silver:27, Bronze: 38 } ]);


To retrieve let say Russia record, you can do the following

/// get the Rusia Info /////

var _target:Object = medalsAC.getItemAt(2);


To change its value, use the following codes
///// set the Rusia Info /////
_target["Gold"] = 50;
medalsAC.setItemAt(_target, 2);


If you want to add a new country let say Czech, then you can use the following codes

medalsAC.addItem({ Country: "Czech", Gold: 27, Silver:27, Bronze: 38 });

Comments

Popular posts from this blog

OpenCover code coverage for .Net Core

Android Programmatically apply style to your view

Using Custom DLL with IronPython / Scripts