Getting column names from arrayCollection

I wish to loop over an array collection and access all the elements (columns)

so the arrayCollection looks like


I need to loop over the rows and columns, but dont know the column names, any ideas.
LVL 18
Who is Participating?
Jones911Connect With a Mentor Commented:
Try this:

It worked in AS2 and it wont work for bindable properties but it works for simple objects.

for (var key:String in object)
    data = object[key] ;

where object is your arraycollection item ie ac[0]
PluckaAuthor Commented:
Cool, I tried that but must have had something wrong.
I'm a novice at Flex, ActionScript, and object oriented programming in general.  I'm trying to have a multi-dimension array (arrayCollection) (2 dimension) and want to access the column data using the first dimension (row pointer) (which is a string) as variable to point to the other  columns in the array.  I currently have:
private function getArrayDataValue(currentArray:ArrayCollection,fieldLabel:String):String {
var key:String = fieldLabel;
var displayValue:String = currentArray[key].data;
return displayValue;
I am getting the following error on execution:
Error: Unknown Property: 'freightTerms'.
      at mx.collections::ListCollectionView/[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\collections\]
      at com.olt.transportation.update::UpdateFullView/getArrayDataValue()[C:\adobeFlexTraining\_workspace\FlexBuilder\src\com\olt\transportation\update\UpdateFullView.mxml:55]
      at <anonymous>()[C:\adobeFlexTraining\_workspace\FlexBuilder\src\com\olt\transportation\update\UpdateFullView.mxml:70]

The code calling the function is:
<mx:Label id="freightTerms" text="{getArrayDataValue(updateTR,'freightTerms')}"/>

Any reasonable suggestion will be greatly appreciated.
An arrayCollection is not really a multidimetional array.  Its an array of Objects.

Also to access arrayCollection elements you must use


you cant do myArrayColelction[1]
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.