Skip to main content
Participating Frequently
August 20, 2014
Question

Help with isolating specific keys

  • August 20, 2014
  • 1 reply
  • 406 views

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() == 😎

    {

        gotoAndStop(7);

    } // end if

};





This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
August 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

};

}




Participating Frequently
August 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?

kglad
Community Expert
Community Expert
August 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?