I am trying to set up some code that lets a user navigate (highlight and then select) a set of buttons using the keyboard.
I am getting this error : Line 40, 1136: Incorrect number of arguments. Expected 1.
I just want the function highlightButton(); to be called whenever a key is pressed. The function finds out which button is targeted via an array.
I must not understand events in as3 yet because I always get errors when I try to called functions by just putting it in there.
stop();
import flash.display.*;
import flash.events.TimerEvent;
import flash.utils.Timer;
var highlightedButton=0;
var holdButtons:Array = new Array();
holdButtons[0]="btn1";
holdButtons[1]="btn2";
holdButtons[2]="btn3";
holdButtons[3]="btn4";
holdButtons[4]="btn5";
function highlightButton(event:Event) {
//button mc go to highlight state
holdButtons[highlightedButton].gotoAndStop("highlight");
trace("BUTTON :" + highlightedButton);
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);
function KeyPressed(evt:KeyboardEvent):void {
switch (evt.keyCode) {
case Keyboard.UP :
trace("up");
--highlightedButton;
highlightButton();
break;
case Keyboard.DOWN :
trace("down");
++highlightedButton;
highlightButton();
break;
/**
case Keyboard.LEFT :
trace("left");
break;
case Keyboard.RIGHT :
trace("right");
break;
**/
}
}