Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Frame navigation with key press

Explorer ,
Feb 06, 2019 Feb 06, 2019

let's say from frame one I want to go to frame two. But instead of clicking on a button with a mouse, I use the key binds instead. Problem is when I press on the keys, it doesn't work.

Heres the code I tried to reenact.

import flash.events.KeyboardEvent;

import flash.ui.Keyboard;

function keyDownHandler(e:KeyboardEvent):void

{

     if (currentScene.name == "Frame 1")

     {

          if (e.keyCode == Keyboard.E)

               gotoAndStop(2);

     }

     else if (currentScene.name == "Frame 2")

     {

          if (e.keyCode == Keyboard.F)

               gotoAndStop(3);

     }

     else if (currentScene.name == "Frame 3")

     {

          if (e.keyCode == Keyboard.G)

               gotoAndStop(4);

     }

}

stop();

if (!stage.hasEventListener(KeyboardEvent.KEY_DOWN))

     stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);

Thanks

396
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 06, 2019 Feb 06, 2019

Hi.

You want to move from frame to frame, but you're checking for scenes names:

if (currentScene.name == "Frame 2")

Shouldn't it be something like:

if (currentLabel == "home")

or

if (currentFrame == 1)

?

Please let us know.

Regards,

JC

Translate
Community Expert ,
Feb 06, 2019 Feb 06, 2019

Hi.

You want to move from frame to frame, but you're checking for scenes names:

if (currentScene.name == "Frame 2")

Shouldn't it be something like:

if (currentLabel == "home")

or

if (currentFrame == 1)

?

Please let us know.

Regards,

JC

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 06, 2019 Feb 06, 2019

Wow, what a quick reply. I was still editing my post. :0

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2019 Feb 06, 2019
LATEST

Haha!

Excellent!

You're welcome!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines