9 Replies Latest reply on Apr 6, 2007 6:00 AM by pluhn

    Finish playing loop, then move on

    pluhn
      I'm somewhat of an amateur when it comes to ActionScripting, since I'm more of an artist than a coder.

      I've got a stretch of 60 frames that are looped, repeating an animation. I want to make it so when I click a button, first the looped frame finish playing from that point, then move on to a specified frame. This is so the animation smoothly transitions from the looped portion to the new portion. Any help would be greatly appreciated.
        • 1. Re: Finish playing loop, then move on
          mheddle
          on(release){

          //stop animation
          animation.gotoAndStop(animation._currentframe);

          //goto specified frame
          instancename.gotoAndStop("frame number");

          }
          • 2. Re: Finish playing loop, then move on
            pluhn Level 1
            That's along the lines of what I'm looking for, but I still need it to finish playing the rest of the frames of the animation before it stops.
            • 3. Re: Finish playing loop, then move on
              pluhn Level 1
              Ok, so I've been playing around with this and still can't get it. I've got the following script in place on the button but it still jumps straight to frame 95 without waiting for the movieclip to be at frame 62, causing a jerky transition in the animation:

              on (release) {
              if (basin_mc._currentframe=62) {
              gotoAndPlay(95);
              }
              }
              • 4. Finish playing loop, then move on
                mheddle Level 1
                on if statements you must use the boolean value of equals == not =. When you use = it acts as if anything in the if statement is true and executes.
                However, the code still won't work because on(release) is a one time action at that given instance.

                On the main timeline create variable _root.ready=0;
                Try adding a frame 63 that is a duplicate to 62. On only frame 62 put code:

                function onEnterFrame() {
                if(_root.ready==1) {
                this.gotoAndStop(63);
                }
                else{
                this.gotoAndPlay(1);
                }
                }

                ...on frame 63 only, put code:
                _parent.gotoAndPlay(95);

                on button put code:

                on (release) {
                _root.ready=1;
                }


                Does this make sense?
                • 5. Finish playing loop, then move on
                  pluhn Level 1
                  Ok, I tried your suggestion and it sort of works. I think I understand what we're trying to tell it to do, but somethings still not right. I plugged it all into a fresh document with placeholders. It plays till frame 62, then goes back to frame 1 like it should, but then it doesn't play again. And when the button is clicked, it goes to frame 63 but doesn't go on to frame 95 like it should.

                  Here's the file if you want to take a look around: Test02.fla
                  • 6. Re: Finish playing loop, then move on
                    mheddle Level 1
                    Is it frame 95 of the animation, button, or main timeline? Does both the button and the animation reside on the main timeline?
                    • 7. Finish playing loop, then move on
                      pluhn Level 1
                      Frame 95 of the timeline. That's the spot on the timeline that the animation will continue from frame 62/63. Currently everything is on the timeline with no movie clips being used for the sake of simplicity.
                      • 8. Re: Finish playing loop, then move on
                        mheddle Level 1
                        I got your FLA. I wasn't exaclty sure where all the objects resided. Okay, take th function onEnterframe{ and the last } of frame 62 out which leaves:
                        if(_root.ready==1) {
                        this.gotoAndStop(63);
                        }
                        else{
                        this.gotoAndPlay(1);
                        }

                        then remove the _parent. from frame 63 so to reads:

                        gotoAndPlay(95);


                        ...and it works

                        The _parent code is for if you are trying to reference some thing outside of your object, such as code inside a movieclip that is trying to reference the main timeline. The main timeline is the _parent in reference to the movieclip.
                        • 9. Re: Finish playing loop, then move on
                          pluhn Level 1
                          Yes, that's exactly what I'm looking for. Thanks a lot for your help, I appreciate it. Like I said, I work as a graphic artist so I have a really hard time grasping the coding stuff.