3 Replies Latest reply on Apr 9, 2010 9:09 PM by webqaflash

    Actionscript stop / start command HELP required

    NathanBone

      Hi All,

       

      I am very new to actionscripting, so please forgive my low understanding of it at this time. I am putting together my first flash presentation and nearly go all my slides together. Within each slide I have animations and been able to create a simply 'stop' 'start' function usings elements as buttons.

       

      However, I want to achieve the same with a mouse or keyboard click, much in the same way Powerpoint works. I understand I need an event handler? I have tried to compose this code, but it does not work :@(

       

      Any tips would be greatfully received.

       

      Nathan

       

      -------------------------

       

      stop ();

       

      // 1. Event handler function

      function clickHandler(event:KeyboardEvent.KEY_DOWN

      ) :void

      {

      trace("SPACE");

      this._parent.nextFrame()

      }

       

      // 2. Assign Listener

      a.addEventListener(KeyboardEvent.KEY_DOWN

      , clickHandler);

        • 1. Re: Actionscript stop / start command HELP required
          webqaflash Level 3

          This will help you

           

          var myListener:Object = new Object();
          myListener.onKeyDown = function () {
              switch (Key.getCode()) {
                  case Key.SPACE :
                      trace("space");

           

                      break;
                  case Key.LEFT :
                      trace("left");
                      break;
                  case Key.UP :
                      trace("up");
                      break;
                  case Key.RIGHT :
                      trace("right");
                      break;
                  case Key.DOWN :
                      trace("down");
                      break;
              }
          }
          myListener.onKeyUp = function () {
              trace ("You released a key.");
          }
          Key.addListener(myListener);

          • 2. Re: Actionscript stop / start command HELP required
            NathanBone Level 1

            Hi Fella,

            Thanks for that, sorry I know I am going to sound really dumb here, do I add this to the original code I have, or removed everything and just put your new code? Tried both, neither seems to work

             

            Basically what I am trying to achieve is that I have 3 slides that I am trying to link together a bit like a power point presentation, within each slide there is a series of bullet points that are animated, I have labelled each animation: a, b, c, etc.

             

            What I am trying to achieve is that in between each animation, the animation stops, then on a keyboard click or mouse click, the animation resumes until the next 'Stop' command.

             

            I was able to get the 'stop' and 'play' command to work by setting each animation as buttons, that when hit prompted the animation. I did this by using this code:

             

            stop ();

            d. onKeyDown = function() {

            this._parent.nextFrame()

            }

             

            But as the end product I want to create is in effect a powerpoint presentation set in flash, I need to learn how to use the keyboard or mouse to do the same.

             

            Any ideas???

             

            Many Thanks

             

            Nathan

            • 3. Re: Actionscript stop / start command HELP required
              webqaflash Level 3

              var myListener:Object = new Object();
              myListener.onKeyDown = function () {
                  switch (Key.getCode()) {
                      case Key.SPACE :
                         //put your actions here for the space button.

               

                          break;
                      case Key.LEFT :
                          //put your actions here for the left button.
                          break;
                      case Key.UP :
                          //put your actions here for the up button.
                          break;
                      case Key.RIGHT :
                           //put your actions here for the right button.
                          break;
                      case Key.DOWN :
                           //put your actions here for the downbutton.
                          break;
                  }
              }
              myListener.onKeyUp = function () {
                  trace ("You released a key.");
              }
              Key.addListener(myListener);