3 Replies Latest reply on Aug 7, 2006 7:24 AM by Nixy

    Return to last scene viewed

    stevie mcg


      I have a scene that can be accessed from every scene in the movie. This scene has 2 options - 1 launches another movie the other is a cancel button.

      When the cancel button is clicked I want to return to the scene you were in last. I have tried the PrevScene function but that just goes to the scene before this scene in the Scene list.

      I am guessing I will have to use variables but I don't have the first clue as to where I would start with that.

      Any help would be gratefully appeciated as I am banging my head against a brick wall here!

      Cheers,

      Stevie
        • 1. Re: Return to last scene viewed
          Nixy Level 1
          Ok
          First one thing to know is, when Flash Compile your document on Publish, all scene became one scene. Here is what I suggest:

          1- Put a label name on each scene at the first frame - Must be unique
          2- On the root, first frame of all, setup 2 things
          - 2 Variables like
          var actPos:String = null;
          var lastPos:String = null;

          - a function :

          function setMyPos(theLabelName:String):Void {
          lastPos = actPos;
          actPos= theLabelName;
          }

          3- Call this function on each first frame of each scene like setMyPos(sceneName);

          I supposed that when you call a new scene you arrive there by the fisrt frame. So this will always keep the actual scene and the last visited scene. When you will need to call the last visited scene, just have to call it like that : gotoAndPlay(_root.lastPos);

          This will bring you at the last visited scene.

          Hope that can help you!
          • 2. Re: Return to last scene viewed
            kglad Adobe Community Professional & MVP
            nixy's suggestion should work if you correct two possible issues. first, don't send sceneName when you call setMyPos unless sceneName is the frame label of the first frame in your scene. second, don't use the goto function. use the goto method:

            • 3. Re: Return to last scene viewed
              Nixy Level 1
              I'm agree with you
              That is the reason why I wrote : "I supposed that when you call a new scene you arrive there by the fisrt frame."
              Also it's true you have to use the _root. before the gotoAndPlay. So _root.gotoAndPlay(lastPos);
              We never know from where you call this methode, so...

              Tanx to correct me.