1 Reply Latest reply on Nov 1, 2011 4:21 AM by Ned Murphy

    Target main timeline within a MC?

    changedname123

      I currently have an annoying problem which I can't seem to get my head around.

       

      What I am trying to do is to make a moveclip change the frame of the main timeline.

      Right now, I have a moveclip on frame 5 with the code:

       

      on (keypress "1") {

          _root.gotoAndStop(10);

      }

       

      When I test the scene (ctrl+alt+enter), it works correctly and when 1 is pressed, the frame is changed.

      However, when I play the scene (ctrl+enter), it does not work and when 1 is pressed, it remains on the frame.

       

      The question I have is what am I doing wrong haha?...Why is it that when I test the scene it works but when I play the scene it doesn't?

        • 1. Re: Target main timeline within a MC?
          Ned Murphy Adobe Community Professional & MVP

          That code should work when testing either way, but it is not a good practice to be placing code on objects.  So what you might try instead is to place the following code in the main timeline...

           

          var keyListener:Object = new Object();
          Key.addListener(keyListener);

           

          keyListener.onKeyDown = function(){
              // trace(Key.getCode());
              if(Key.getCode() == 49) gotoAndStop(10);;  // 49 is hey 1
          }