List component Help

Hi,

Im using the List component as a menu. The user uses the arrow keys to go up and down the items in the component and uses another key to select them. This is all working but now i would like to include infinite menus. I have made a quick animation to show you what i mean:
http://ahref.theicy.net/i/infm.swf

im currently using this code:


focusManager.setFocus(_root.menu);
lastItem = menu.length - 1;
menu.selectedIndex = 0;
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if((menu.selectedIndex == lastItem)&&(Key.getCode() == 40)){
	
	menu.selectedIndex = 0;
}
if((menu.selectedIndex == 0)&&(Key.getCode() == 38)){
	
	menu.selectedIndex = lastItem;
}

however this results in an “off by one error” and the top item and botom item cant be selected. eg.
http://ahref.theicy.net/i/offbyone.swf

does anyone know how i can fix this?

if you dont understand please ask ill try and explain more:)

thanks