elektroluse elektroluse - 4 months ago 26
ActionScript Question

AS3 referencing a list item which has no name

list.addItem({label:"a"});


When you add an object to the list like this, how do you reference to it later without using a listener for the list and then going

list.selectedItem


Are list items not indexed like arrays? I would want to do something like this

trace(list.item[0].label);


And have it return "a" Is this not possible with lists?

Answer
list.dataProvider.length // gets total number of items
list.dataProvider.getItemAt(0) // gets first item
list.dataProvider.getItemAt(0).label // gets the first item label

See all the methods here.. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/data/DataProvider.html