开发者

AS3 getting a List item index on a mouse roll over event

I am trying to get the index of an item in a List object on a mouse roll over event (please keep in mind this is not the selectedIndex I need). Heres the code i am currently using:

list.addEventListener(ListEvent.ITEM_ROLL_OVER, onItemRollOver);
function onItemRollOver(e:Event):void {
var itemInfo:Number = 0;

/*
    THIS IS WHERE I NEED THE INDEX NUMBER OF THE ITEM BEING ROLLED OVER INSTEAD OF THE SELECTED ITEM
*/
itemInfo = list.selectedIndex; 

txt_Display.text = 'Item Index #: ' + 开发者_StackOverflow社区itemInfo;

play();
}

Thanks in advance for the help!


It's in the event your listener function takes as a parameter.

This should work:

itemInfo = e.index;


Just to clarify heres the final code that works:

list.addEventListener(ListEvent.ITEM_ROLL_OVER, onItemRollOver);
function onItemRollOver(e:ListEvent):void { 
var itemInfo:Number = 0;

itemInfo = e.index;

txt_Display.text = 'Item Index #: ' + itemInfo;

play();
}

Thanks again for the help!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜