5 Replies Latest reply on Sep 29, 2007 6:35 PM by kglad

    Timeline frame control issue

    Chris Mattingly Level 1
      Hi,

      I'm having a hard time understanding how to control playback of frames in my Flash animation. Basically, I have a file that is 40 frames long (this is a test file for a larger project). I want the first 20 frames to only play once, and the last 20 to loop repeatedly. My line of thinking was that the gotoAndPlay script (inserted at frame 40) should be the way to go, but I can't get it to work right. Here is the code I've tried:

      import flash.display.MovieClip;
      bouncyball.gotoAndPlay(startbounce,1);

      Bouncyball would be the 2nd movie clip (from frames 21-40), and startbounce is the label for frame 21. I've tried a few other things, but nothing's working. I'm also wondering if I should be trying to control the timeline from an empty layer that only contains actions, or if there's a better approach. With the script assist turned on, the gotoAndPlay function seems to want you to point to an object, where I really want is just to jump to another frame in the main timeline.

      One last question: are there any books on controlling timeline playback that would be recommended? Thanks much
        • 1. Re: Timeline frame control issue
          pajaroplus Level 1
          if you add the actions to the timeline were the 40 frames are this should be enough

          import flash.display.MovieClip;
          gotoAndPlay(21);

          or

          import flash.display.MovieClip;
          gotoAndPlay("frameLabel");
          • 2. Timeline frame control issue
            Chris Mattingly Level 1
            Thanks for the answer, pajaroplus!

            It did the trick, with some odd quirks that I still don't understand.

            1. Removing the object reference was the key, and...

            2. For whatever reason, referencing the frame label absolutely will not work, but the frame number did the trick (minus a reference to the scene number).

            I have SOOOO much to learn before I'll be designing entire sites in Flash.

            Have a great weekend
            • 3. Re: Timeline frame control issue
              kglad Adobe Community Professional & MVP
              you should use a timeline/movieclip reference and using frame labels or numbers both work well. for example:

              _root.gotoAndPlay("startbounce"); // assuming startbounce is the label for frame 21.

              your code containing both a variable (startbounce) and a number (1) in your gotoAndPlay() makes no sense. in particular, startbounce is not a frame label.
              • 4. Re: Timeline frame control issue
                Chris Mattingly Level 1
                quote:

                Originally posted by: kglad
                you should use a timeline/movieclip reference and using frame labels or numbers both work well. for example:

                _root.gotoAndPlay("startbounce"); // assuming startbounce is the label for frame 21.

                your code containing both a variable (startbounce) and a number (1) in your gotoAndPlay() makes no sense. in particular, startbounce is not a frame label.
                Thanks, KGlad. I got it working -- I can't explain why, but for some reason referencing the frame label absolutely will not work, but frame # works fine.

                I failed to mention in my original post, but I was using AS 3. The code you suggested would be used for AS 2, wouldn't it?

                Following along w/ the script assist is where I came up with that odd, extraneous code. It's a little misleading; it gives you 3 entry fields for the script (object, parameter and scene), and I only needed one to make gotoAndPlay work properly.
                • 5. Re: Timeline frame control issue
                  kglad Adobe Community Professional & MVP
                  yes, that's as2 code. _root is an as2 timeline. root would be the as3 equivalent.

                  scene information shouldn't be used for navigation even when referring to the main timeline (where different scenes can exist). of course, you have no scenes in bouncyball.

                  using the frame label will work, but you must use a string (object or reference) in your goto method. again, startbounce is not a string. it might be a variable that contains a string, but that's not apparent from your code and it's my guess that it's not a variable.