Back Button

One of the criticism of flash movies is that there is no back button like in browsers for HTML pages. So I created a simple script, which allows to go back at least to the previous frame. I am als looking into to go back to more frames but not yet.

Here is the actionscript. First you create buttons of a menu for example and add the script. If in a frame there is only a back button, then enter the framename into a keyframe on the timeline. I did that on my site with go-back-to-selection button.

//we first create a new array object.
myArray=new Array();
//then we define a function called "listFrame", which is the main function
//for the buttons.
function listFrame(){
    //we add values for the global var "_global.fVar" to the array every
    //time a button is pushed
    myArray.push(_global.fVar);
    //then we define the var _global.sliced, which is the first element of the array
    //by using "shift().toString()". The very first value will be undefined,
    //because there is no value in the array, but then the values will be
    //the frame names. This var is a global var because the value will be remembered
    //everywhere in the movie.
    _global.sliced=myArray.shift().toString();
    textBox.text="Frame to go back to is     "+_global.sliced+".";
}

//and then define the back button to go to the value of _global.sliced.
backbut.onRelease=function(){
    gotoAndStop(_global.sliced);
}
//Here we define all the other buttons by creating one common function
//for buttons. If you use movieclips as buttons you have to change the function.
//The parameter "frameName" is the name of the frame to go to.
Button.prototype.goBackToFrame=function(frameName){
    this.onRelease=function(){		
    listFrame();
    _global.fVar=frameName;
    gotoAndPlay(frameName);
    }
}
//Here the functions are executed.
menubut1.goBackToFrame("frame1");
menubut2.goBackToFrame("frame2");
menubut3.goBackToFrame("frame3");
menubut4.goBackToFrame("frame4");
menubut5.goBackToFrame("frame5");
returnbut.goBackToFrame("menu");