AS3 Keyboard script
I have 101 frames that I want to advance or return by using the left and right keyboard arrows. One Caveat, when I am on frame 1; I want the Right arrow to go to frame 101. I used this code:
stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown);
function myKeyDown(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.RIGHT)
{
gotoAndStop(101);
}
}
Works fine. But when I am on frame 101, I want the playhead to go to frame 2 when pressing the right arrow, and to frame 1 when pressing the left arrow. Then when I am on frame 2, I want the player to go to 3 when pressing the right arrow and back to 101 when pressing the left arrow. From frame 3 - frame 100 simply next frame or previous frame. From frame 100, the right arrow should bring it to 1.
In a nutshell, I have a number on each frame that corresponds to the frame number. Since Frame one is set up as a landing page, I am using 101 as my frame 1. I could put the above code on each frame, but that seems like too much work. I'm an AS2 guy and can no longer access my CS6, so I'm forced to try to replicate super easy code with AS3. Can anyone help me? Can this be written with 'if' statements? I tried but Animate just kept crashing.
