3 Replies Latest reply on Jan 3, 2007 5:16 PM by Jon Mattarocchia

    Button that goes back to last keyframe

    Jon Mattarocchia
      i created a flash animation like whats here "the headline news section in the middle of the page" now my problem is getting my forward and back buttons to work. how can i make it so when somone clicks on the forward button it skips to the next frame if they dont want to wait for it to get there by itself? heres what i got now now i tried doing on (release) { gotoAndPlay ("frame number"); } now it goes to that frame but all the images that fade in and out are not in sink anymore and it doesnt play it just stays on that frame with the images fading in and out, out of sink. any help would be great.
      Thanks
      -Jon
        • 1. Re: Button that goes back to last keyframe
          dr.Evol Level 1
          you have to somehow store the last visited keyframe and then reference this variable when you move back to the last keyframe.

          create a variable : var f:Number;

          then on each keyframe put: f=this._currentframe;

          on the first frame of your main timeline put the following code to controll the buttons:

          var ref=this;
          btnFW.onPress=function() { //this one is for moving forward
          ref.play();
          }

          btnRW.onPress=function() { // this one is for going back to the last keyframe
          ref.gotoAndStop(ref.f); //or put gotoAndPlay if you want to play from this frame on
          }

          Why your images are fading I haved no idea since you didnt provide any detailed info about you app. Probabbly your images are separate animations and therefore you'll need to controll them separately.

          cheers

          • 2. Re: Button that goes back to last keyframe
            Jon Mattarocchia Level 1
            i have 3 layers the first layer is the background the 2nd is the buttons and the thrid is the images. i turned each image into a movie clip. where it fades in and then fades out.
            • 3. Re: Button that goes back to last keyframe
              Jon Mattarocchia Level 1
              quote:

              Originally posted by: dr.Evol
              you have to somehow store the last visited keyframe and then reference this variable when you move back to the last keyframe.

              create a variable : var f:Number;

              then on each keyframe put: f=this._currentframe;

              on the first frame of your main timeline put the following code to controll the buttons:

              var ref=this;
              btnFW.onPress=function() { //this one is for moving forward
              ref.play();
              }

              btnRW.onPress=function() { // this one is for going back to the last keyframe
              ref.gotoAndStop(ref.f); //or put gotoAndPlay if you want to play from this frame on
              }

              Why your images are fading I haved no idea since you didnt provide any detailed info about you app. Probabbly your images are separate animations and therefore you'll need to controll them separately.

              cheers




              i added var ref=this;
              btnFW.onPress=function() { //this one is for moving forward
              ref.play();
              }
              to the first frame of the button timeline on the button and i got this error.

              **Error**Scene=Scene1, Layer=Layer1, frame=Frame1: statement must apear within on handler
              var ref=this;


              **Error**Scene=Scene1, Layer=Layer1, frame=Frame1: statement must apear within on handler
              btnFW.onPress=function()