Setting up a keypad navigated button menu using an array

Hi there,

I’ve gotten code that would circle through this with menu without an array, but I have been looking trying to complete it for the sake of better learning about arrays.

I have 3 buttons and I want to use the up, down, arrow keys to cycle through the buttons. So far I have the code to switch the up state once they are clicked on but I am unsure how to incorporate the navigational aspect into the array and have it cycle through.

Below I have posted my file with actionscript. Here is the actionscript set up right now:

[AS]btn1.gotoAndStop(1);
btn2.gotoAndStop(1);
btn3.gotoAndStop(1);

var buttons:Array = [“btn1”, “btn2”, “btn3”];

function buttonOver(pressed) {
for (var i = 0; i<buttons.length; i++) {
if (pressed == buttons*) {
this[buttons*].gotoAndStop(2);
this[buttons*].enabled = false;
} else {
this[buttons*].gotoAndStop(1);
this[buttons*].enabled = true;
}
}
}

btn1.onRelease = function ():Void {
buttonOver(“btn1”);
}

btn2.onRelease = function ():Void {
buttonOver(“btn2”);
}

btn3.onRelease = function ():Void {
buttonOver(“btn3”);
}

[/AS]