Define array with Array collection in ActionScript and use it for DataGrid
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="creationCompleteHandler(event)">
<mx:Script>
import mx.collections.ArrayCollection;
private function creationCompleteHandler(event:Event):void {
var array:Array = new Array({city: "A", state: "CA",population: 3},
{city: "B", state: "NY",population: 8},
{city: "C", state: "IL",population: 2},
{city: "D", state: "PA",population: 1});
var collection:ArrayCollection = new ArrayCollection(array);
grid.dataProvider = collection;
}
</mx:Script>
<mx:DataGrid id="grid" width="500" />
</mx:Application>
Related examples in the same category