Back button to previous frame

  • hal16366
  • Born
  • Born
  • hal16366
  • Posts: 4

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

try this:

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


This should stop on the previous frame.
  • hal16366
  • Born
  • Born
  • hal16366
  • Posts: 4

Post 3+ Months Ago

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
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

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.
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

btw: I believe ActionScript is case sensitive, so...
"GotoAndPlay" doesn't equal "gotoAndPlay"
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

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;
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Good catch dM, I diddn't see the Goto error.
  • hal16366
  • Born
  • Born
  • hal16366
  • Posts: 4

Post 3+ Months Ago

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
  • Robinod8
  • Posts: 2

Post 3+ Months Ago

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
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

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?
  • Robinod8
  • Born
  • Born
  • Robinod8
  • Posts: 2

Post 3+ Months Ago

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
  • Posts: 5149
  • Loc: SC-USA

Post 3+ Months Ago

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?
  • joaodjesus
  • Born
  • Born
  • User avatar
  • Posts: 2

Post 3+ Months Ago

Hi, sorry to bring this topic back to life, but i am looking for a way of making basically the same thing.

I am working in AS2.0 (i am editing a old flash applicattion)

Wath i want to do is create a button that always take me back to the last frame i was in.

i have 2 that go to the same frame, ex

the Frame 5 and the Frame 10 have buttons that go to the same frame, like 15/ or 16...

But when we are in the frame 15 and hit the back button it needs to go back to the frame 5, because that was were i was before i get to the frame 15.

If someone can help i will really appreciate.

Sorry for my bad English, if you dont understand some thing, please ask.

Post Information

  • Total Posts in this topic: 13 posts
  • Users browsing this forum: No registered users and 9 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
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.