ActionScript 3.0 list listener?
In ActionScript 3.0, I have code that displays a list. When a row is selected, how开发者_高级运维 do I add a listener to execute code and how do I extract the position of the selected row
If it's an MX list:
To add the event listener:
list.addEventListener(ListEvent.ITEM_CLICK, onListItemClick);
To get the selected row:
public function onListItemClick(le:ListEvent):void
{
var selectedItem:int = le.rowIndex;
}
if it's a FL list:
To add the event listener:
list.addEventListener(Event.CHANGE, onListItemChange);
To get the selected row:
public function onListItemChange(e:Event):void
{
var selectedIndex:int = list.selectedIndex;
}
精彩评论