tags:

views:

351

answers:

1

How to enumerate items of Spark List component after setting dataProvider property?

I mean accessing them as DisplayObject instances.

A: 

Iterate over list.dataGroup.numElements, calling list.dataGroup.getElementAt(i):

var i:int = 0;
var n:int = list.dataGroup.numElements;
for (i; i < n; i++)
{
    // getElementAt returns an IVisualElement, but most displayobjects
    // in a list will be IVisualElement (which a UIComponent implements)
    var displayObject:DisplayObject = list.dataGroup.getElementAt(i) as DisplayObject;
}
viatropos