2 Replies Latest reply on May 5, 2007 1:54 PM by bgersak

    how can I assign actions to buttons using keyboard (different keys)

    bgersak
      I would like to assign (with action script 3.0) to a specific button two actions;
      1. pressing the key arrow down = play movie which was paused,
      2. pressing the key arrow up = go to specific frame in movie (back in timeline).

      How can I do that.
      Thanks.
        • 1. how can I assign actions to buttons using keyboard (different keys)
          MichaelS Level 1
          Create a listener for the up and down arrows. Add/Modify the following action and place it on your main timeline:

          myListener = new Object();
          myListener.onKeyDown = function() {
          //play paused movie code where 'myMovie' is the movieclip's instance name
          myMovie.play();
          };
          myListener.onKeyUp = function() {
          //goto frame # in myMovie and Play
          //Could also use gotoAndStop(#) if you don't want the
          //movieclip to continue playing
          myMovie.gotoAndPlay(#);
          };
          Key.addListener(myListener);

          Not sure if it's different for Actionscript 3.0.
          • 2. Re: how can I assign actions to buttons using keyboard (different keys)
            bgersak Level 1
            The movie (actually timeline), which is paused was paused by a keyframe (stop). There are several stops at specific time in timeline. For all those stops I would like to contunue on the keypress. How can I define which key is for forward and which for go to frame? The script did not work.
            Perhaps I can send some jpeg pictures from my test movie. The stop command is working, also click on the mouse, just the key I cannot assign.
            For mouse I use this script:

            inv_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
            function buttonClickHandler(Event:MouseEvent):void {
            play();
            }

            instead of click on mouse I would like to pres any key (let us say key B or arrow down).
            Thanks.