I coded a BACK button so that it would go back to the previous frame on the timeline, wherever that frame might have been. I got code off the internet. This is it:
Steps to making a ‘Back’ button:
- In the first frame of the movie, initialize an array which holds all the interesting frames that are to be visited:
[INDENT] [FONT=Courier New]navStack = [];[/FONT]
[/INDENT] 2. In each interesting frame, add a script to that frame number so that it’s on the list of interesting frames that are to be visited:
[INDENT] [FONT=Courier New]navStack.push(_currentFrame);[/FONT]
[/INDENT] 3. Put the following script on the ‘Back’ button that sends the playback head past the most recent interesting frame to the previous interesting frame:
[INDENT] [FONT=Courier New]on (release) {
if (_root.navStack.length > 1) {
[/FONT][INDENT][FONT=Courier New] recentFrame = _root.navStack.pop();
previousFrame = _root.navStack.pop();
gotoAndPlay(previousFrame);
}
[/FONT][/INDENT][FONT=Courier New] } [/FONT]
[/INDENT] All was well and good until, for purposes of the preloader, I put everything that I had on the main “parent” timeline into a “child” movie clip. I changed all references to “_root” to “this”. The back button should work, right?
Wrong. It does nothing. It goes nowhere.
What have I missed?