Highlighted

Frame navigation with key press

Explorer ,
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

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

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

TOPICS
Discussions

Views

119

Likes

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

Frame navigation with key press

Explorer ,
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

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

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

TOPICS
Discussions

Views

120

Likes

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
Feb 06, 2019 0
Adobe Community Professional ,
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

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Feb 06, 2019 0
Explorer ,
Feb 06, 2019

Copy link to clipboard

Copied

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

Thanks

Likes

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
Reply
Loading...
Feb 06, 2019 1
Adobe Community Professional ,
Feb 06, 2019

Copy link to clipboard

Copied

Haha!

Excellent!

You're welcome!

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Feb 06, 2019 0