Help setting up arrow key navigation from label to label.
I tried editing some code I was able to use to add button click navigation from label to label.
My goal was to setup backwards and forward navigation using the keyboard.
I've clearly messed something up big.
Can anyone help me fix this code???
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyboardHandler);
var myLabels:Array = ["intro","study_obj","exec_sum","country","submenu","us","china","germany"];
var nextLabel:String;
var inc:int = -1;
var PrevLabel:String;
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyboardHandler);
function KeyboardHandler(event:KeyboardEvent):void
{
if(event.keyCode == 37)
{
inc++;
if(inc < myLabels.length){
gotoAndPlay(String(myLabels[inc]));
} else {
inc = 0; // keep it at the start
}
}
function KeyboardHandler(event:KeyboardEvent):void
{
if(event.keyCode == 39)
{
{
inc--;
if(inc > -1 ){
gotoAndPlay(String(myLabels[inc]));
} else {
inc = myLabels.length - 1; // keep it at the end
}
}
Sorry. I'm a newbie and having trouble.
Thank you!
