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

Frame navigation with key press

Explorer ,
Feb 06, 2019 Feb 06, 2019

Copy link to clipboard

Copied

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

Views

261

Translate

Translate

Report

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

Votes

Translate

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Thanks

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

Haha!

Excellent!

You're welcome!

Votes

Translate

Translate

Report

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