Back button to previous frame

  • hal16366
  • Born
  • Born
  • No Avatar
  • Joined: Aug 31, 2004
  • Posts: 4
  • Status: Offline

Post August 31st, 2004, 9:39 am

I've developped a Flash movie with 200 frames aprox. It's possible to go to whatever frame from whatever other frame. I have created a "back button" in every this 200 frames. The function of this "back button" is to come back to the frame previous that I was.

I have tried to solve with this code in every frame:

a) At the previous frame:
/:prevframe = _root._currentframe

b) At the current frame (on the "back button":
on (release){
GotoAndStop (prevframe);}

That doesn't work. Could you help me, please ?. Thanks a lot
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post August 31st, 2004, 9:39 am

  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Joined: Dec 29, 2003
  • Posts: 5169
  • Loc: SC-USA
  • Status: Offline

Post August 31st, 2004, 10:28 am

try this:

Code: [ Select ]
on(release) {
 prevFrame();
}
  1. on(release) {
  2.  prevFrame();
  3. }


This should stop on the previous frame.
- dM
  • hal16366
  • Born
  • Born
  • No Avatar
  • Joined: Aug 31, 2004
  • Posts: 4
  • Status: Offline

Post August 31st, 2004, 10:37 am

Thanks for your quisk answer.
maybe I don't explain very well my problem.

Your solution is to move to inmediate pevious frame in the movie, but I need some solution to move to frame I was before and usually, that frame will not the inmediate previous frame. It's similar to the "breadcrumbs" problem. In my case I need only to skip to the last frame. Thanks
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Joined: Dec 29, 2003
  • Posts: 5169
  • Loc: SC-USA
  • Status: Offline

Post August 31st, 2004, 11:31 am

Sorry about that. :)

This worked for me...

Frame script:
Code: [ Select ]
backFrame=_currentframe;


Button script:
Code: [ Select ]
on (release) {
    gotoAndStop(backFrame);
}
  1. on (release) {
  2.     gotoAndStop(backFrame);
  3. }


I changed the variable you were using because it's the same name as a predefined function in Flash.
- dM
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Joined: Dec 29, 2003
  • Posts: 5169
  • Loc: SC-USA
  • Status: Offline

Post August 31st, 2004, 11:35 am

btw: I believe ActionScript is case sensitive, so...
"GotoAndPlay" doesn't equal "gotoAndPlay"
- dM
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post August 31st, 2004, 11:37 am

making the previous frame variable _global will make it available to your button, I'd change the name of that variable so it's not the same as the prevFrame method as well.
Code: [ Select ]
//first frame
_global.lastVisited = root._currentframe;
  1. //first frame
  2. _global.lastVisited = root._currentframe;
Strong with this one, the sudo is.
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post August 31st, 2004, 11:40 am

Good catch dM, I diddn't see the Goto error.
Strong with this one, the sudo is.
  • hal16366
  • Born
  • Born
  • No Avatar
  • Joined: Aug 31, 2004
  • Posts: 4
  • Status: Offline

Post September 1st, 2004, 6:50 am

thanks all. I've test the solution with a bad environment. Your confirmation have helped me that the was that (the "environment").

Problem solved !!!.
  • Robinod8
  • Born
  • Born
  • No Avatar
  • Joined: Sep 28, 2004
  • Posts: 2
  • Status: Offline

Post September 28th, 2004, 6:20 pm

So, I'm trying to do the same thing I think. I have a project of about 35 Frames on the main timeline but several movieclips throughout. In order for the Script to work, do I need to place

//first frame
_global.lastVisited = root._currentframe;

on each frame in the timeline & movieclips and then attach

on (release) {
gotoAndStop(backFrame);
}

I've attached the //first frame script to the frames in the main timeline and then the button script to the button and it doesn't appear to be doing anything, but I'm not getting an error message either.

Help .. Thanks so much!
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Joined: Dec 29, 2003
  • Posts: 5169
  • Loc: SC-USA
  • Status: Offline

Post September 29th, 2004, 9:10 am

In your example, you're capturing and assigning the current frame to the variable "lastVistied". Then you're passing "backFrame" as the argument to the gotoAndStop method. So, these script elements aren't having any relationship.

So, you have 35 frames that are acting like pages. If you are on frame 1, you want to be able to navigate to frame 20, for instance, and then hit a back button to go back to the frame that was viewed previously (frame 1). Is that right?
- dM
  • Robinod8
  • Born
  • Born
  • No Avatar
  • Joined: Sep 28, 2004
  • Posts: 2
  • Status: Offline

Post September 29th, 2004, 9:18 am

Exactly ... but I want to incorporate the movie clip pages if that is at all possible.

Thanks
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Joined: Dec 29, 2003
  • Posts: 5169
  • Loc: SC-USA
  • Status: Offline

Post September 30th, 2004, 5:45 pm

Ok, here's what I'd do.

Forget about buttons. Make the interactive elements movie clips, and don't forget to name the instances. ;)

Put all of your ActionScript in the first frame.

Whenever you navigate away from a frame, you need to capture the frame number (myVar = _currentFrame;)

Then your back button will be "gotoAndStop(myVar);"

The Actionscript in frame 1 might look something like this:
Code: [ Select ]
navigationButton.onPress = function() {
    backFrame = _currentframe;
};
navigationButton.onRelease = function() {
    navigateToNewFrame();
};
backButton.onRelease = function() {
    gotoAndStop(backFrame);;
};
  1. navigationButton.onPress = function() {
  2.     backFrame = _currentframe;
  3. };
  4. navigationButton.onRelease = function() {
  5.     navigateToNewFrame();
  6. };
  7. backButton.onRelease = function() {
  8.     gotoAndStop(backFrame);;
  9. };


However, if you want to be able to back track over a "history", then you'll need to track the current frame numbers in an array.

Does any of this help?
- dM

Post Information

  • Total Posts in this topic: 12 posts
  • Users browsing this forum: No registered users and 35 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.