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

Help with isolating specific keys

Explorer ,
Aug 20, 2014 Aug 20, 2014

Hi, I'm using the script below to isolate specific keys on the keyboard to control the timeline. This works for a while but seems unstable. It causes Flash Player Debugger to run slow and eventually hang and I have to force quit the player.

Any suggestions to help to improve would be grateful.


stop ();

var keyListener = new Object();

Key.addListener(keyListener);

keyListener.onKeyDown = function ()

{

    if (Key.getAscii() == 8)

    {

        gotoAndStop(7);

    } // end if

};





TOPICS
ActionScript
361
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 ,
Aug 20, 2014 Aug 20, 2014

try:


stop ();

var alreadyExecuted:Boolean;

if(!alreadyExecuted){

alreadyExecuted=true;

var keyListener = new Object();

Key.addListener(keyListener);

keyListener.onKeyDown = function ()

{

    if (Key.getAscii() == 8)

    {

        gotoAndStop(7);

    } // end if

};

}




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 ,
Aug 20, 2014 Aug 20, 2014

Thanks kglad, this works well, but if I want to use the same script on the next frame and change the gotoAndStop to frame 8 the key press doesn't seem to work again?

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 ,
Aug 20, 2014 Aug 20, 2014

you want the same keypress to goto frame 7 when the current frame is frame 1 and frame 8 if the current frame is frame 2. anything else?

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 ,
Aug 20, 2014 Aug 20, 2014

The frames numbers don't need to be specific. The one I posted was something I was testing and that code just happened to start at frame 6 of my timeline.

Another example might make it clearer. If I start at frame 1 using that script, I want to stop at each frame ( 2-3-4-5-6-7-8-9-10 ) by using the delete key. Is the script you provided able to do that?

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 ,
Aug 20, 2014 Aug 20, 2014

use:

stop ();

var alreadyExecuted:Boolean;

if(!alreadyExecuted){

alreadyExecuted=true;

var keyListener = new Object();

Key.addListener(keyListener);

keyListener.onKeyDown = function ()

{

    if (Key.getAscii() == 8)

    {

nextFrame();

    } // end if

};

}


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 ,
Aug 20, 2014 Aug 20, 2014

Thanks, will give it a try.

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 ,
Aug 20, 2014 Aug 20, 2014
LATEST

you're welcome.

p.s when using the adobe forums, please mark helpful/correct responses, if there are any.

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