# Setting up a keypad navigated button menu using an array

**URL:** <https://forum.kirupa.com/t/setting-up-a-keypad-navigated-button-menu-using-an-array/294954>\
**Category:** flash\
**Created:** [August 23, 2009, 5:40am UTC](https://forum.kirupa.com/t/setting-up-a-keypad-navigated-button-menu-using-an-array/294954 "2009-08-23T05:40:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jumpsuit1](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@jumpsuit1](https://forum.kirupa.com/u/jumpsuit1)\
**Post date:** [August 23, 2009, 5:40am UTC](https://forum.kirupa.com/t/setting-up-a-keypad-navigated-button-menu-using-an-array/294954/1 "2009-08-23T05:40:39Z")

</div>

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]
