1 Reply Latest reply on Mar 27, 2014 5:55 PM by kglad

    Key Press to named Scene/Frame wont work

    sparrow360

      Hi

       

      First time using Flash in years. I'm using AS2 and Flash CS6.

       

      I have a 4 scene movie and my client wants to right-cursor through the scenes. So it's just like a Powerpoint presentation really.

       

      On each Scene, I have a Button MovieClip whcih tells the movie to advance a Scene.

       

      This works on every Scene bar the first Scene and I just can't understand why.

       

      Here's the AS2 on Scene 1s button. Vs is my next Scene and then the START-VersusScene is my frame label.

       

      on (keyPress "<Right>") {

                gotoAndPlay("Vs", "START-VersusScene");

      }

       

       

      Oddly enough this works perfectly when I just preview the movie but as soon as I publish to HTML it won't work.

      Another oddity is that if I click (mouse) the button and *then* hit my Right Cursor, it works.

       

      I just don't understand whats wrong with the damn thing.

      I know a lot of ppl would say I should be using perhaps AS3 or not scenes or even not "on" events but this is a quick turnaround project and my time to learn all of the above didn't exist.

       

      Many thanks

        • 1. Re: Key Press to named Scene/Frame wont work
          kglad Adobe Community Professional & MVP

          1.  don't attach code to objects (like buttons).  attach code to your main timeline.

           

          2.  don't use the goto functions.  use the goto methods.

           

          3.  don't use scenes for navigation.  use frame labels.

           

          for example,

           

          var lo:Object = new Object();

          lo.onKeyDown = keydownF;

          Key.addListener(lo);

          var tl:MovieClip = this;

           

          function keydownF() {

              if (Key.isDown(Key.RIGHT)) {

                  tl.gotoAndStop('whatever');

              } else if(Key.isDown(Key.LEFT)){

                  tl.gotoAndStop('whatever_else');

              }

          }