2 Replies Latest reply on Jun 21, 2007 8:11 AM by Newsgroup_User

    Key board evenets

    Level 7
      can we call keyboard events programitacally in flash.
      I want to call Key.Right on when i press thea button on stage thats for
      some reason in game. How to do that.

      Its urgetnt


        • 1. Re: Key board evenets
          MaxManNH Level 2
          I don't think you can do that. I think Key.RIGHT is just a constant in the Key class that you can do a comparison against. You can't create a Key.RIGHT event.
          • 2. Re: Key board evenets
            Level 7
            Why not execute the same code for both the key event and the button event?


            function doKeyRightStuff(){
            // do stuff here
            }

            myRightButton.onPress = doKeyRightStuff;

            // OR

            // myRightButton.onRelease = doKeyRightStuff;


            var keyListener:Object = new Object();
            keyListener.onKeyDown = = function(){
            switch (Key.getCode()){
            case Key.RIGHT:
            doKeyRightStuff();
            break;
            default:
            break;
            }
            }