Hi Todd,

One of the ways would be to traverse your ArrayCollection with a cursor:

var cursor:IViewCursor = myAC.createCursor();
var sumPop:int = 0;
var myObject:Object;
while (!cursor.afterLast) {
   myObject = cursor.current;
   sumPop += myObject.population;
}

Jurgen

todd_geist wrote:

Hello,

Very new here. Trying to get some of the basics. I have datagrid
that is populated with the following arrayColleciton

<mx:ArrayCollection id="myAC">
<mx:Array>
<mx:Object city="Los Angeles" state="CA"
population="3844829" />
<mx:Object city="New York" state="NY" population="8143197" />
<mx:Object city="Chicago" state="IL" population="2842518" />
<mx:Object city="Philadelphia" state="PA"
population="1463281" />
</mx:Array>
</mx:ArrayCollection>

How do I go about getting the sum of the population?

Thanks in advance for any advice.

Todd

Reply via email to