Reputation: 14579
I have a regular control in my code with several items.
<mx:List id="myList">
<mx:String>Item 1</mx:String>
<mx:String>Item 2</mx:String>
</mx:List>
I have some other code which runs and populates the list. How do I select the first item in the newly populated list using code?
Upvotes: 1
Views: 4248
Reputation:
Try using the getItemAt method of the List's dataProvider like this... myList.dataProvider.getItemAt(0).
Upvotes: 2
Reputation: 12488
That would be myList.selectedItem
, if you have a reference to the object you would like to select, or myList.selectedIndex
, if you have an index into the data source. Both properties are inherited from the ListBase class. They're documented in the ActionScript 3.0 Language Reference.
Upvotes: 9