Actionscript 3 Navigate with Keyboard Between Labels
- by Sbml
Hello
I need to navigate between labels with arrow keys like a power point presentation.
I have an array with labels and a KeyboardEvent. My problem is, if I am in label number four for example and click in arrow click, always goes to first label. So I need help defining my current label to go to the next on key press.
My code:
import flash.events.KeyboardEvent;
var myLabels:Array = [ "label_1", "label_2", "label_3", "label_4"];
var nextLabel:String;
var inc:int = 0;
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
function keyPressed(evt:KeyboardEvent):void
{
switch(evt.keyCode)
{
case Keyboard.RIGHT :
nextLabel = String(myLabels[inc]);
gotoAndStop(nextLabel);
inc++;
break;
}
}
Thanks