Skip navigation
Currently Being Moderated

How to make a back button?

Jul 27, 2012 7:25 AM

I want to make a back button, but I'm not really sure how to do this. I did some research and some people said you need an array. I've never made an array before. Everyone of my frames have a label and multiple ways to get to that frame. Can anyone help me with this? Any help would be appreciated, thank you.

 
Replies
  • Currently Being Moderated
    Jul 27, 2012 8:24 AM   in reply to John Delamotte

    The array will be a list of your steps

     

    define the array:

     

    var myBackList:Array=new Array();

     

    now every time it you change to another frame, add to the list (array) the label name of the frame

     

    i.e.

     

    myButtonGoToFirstSection.addEventListener(MouseEvent.CLICK, gotoFirstSection)

    function gotoFirstSection(e:MouseEvent):void{

             gotoAndStop("FirstSeccion")

              myBackList.push("FirstSeccion") //this add the the label to the array

    }

     

     

    then the code to the back button is:

     

    myBackButton.addEventListener(MouseEvent.CLICK, goBack)

    function goBack(e:MouseEvent):void{

              gotoAndStop(myBackList.pop())

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 10:21 AM   in reply to John Delamotte

    yes, you must add to each button, the array is a stack and added in the order they arrive, to "back" you will always take the last.

    The pop method, gets the last value and delete it

     

    gotoAndStop(myBackList.pop())

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 14, 2012 1:01 PM   in reply to John Delamotte

    You are not using the same code above,  can you show your code?

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 14, 2012 2:10 PM   in reply to John Delamotte

    stop();

    var myBackList:Array=new Array();

     

     

    bioBut.addEventListener(MouseEvent.CLICK, gotoBiographies);

    overviewBut.addEventListener(MouseEvent.CLICK, gotoOverview);

    commemorationBut.addEventListener(MouseEvent.CLICK, gotoCommemoration);

    GettingStartedButt.addEventListener(MouseEvent.CLICK, gotoAboutTheLesson);

    myBackButton.addEventListener(MouseEvent.CLICK, goBack);

     

     

    function gotoBiographies(event:MouseEvent):void {

        gotoAndStop("bios");

        myBackList.push("bios");

        trace(myBackList)

     

    }

    function gotoOverview(event:MouseEvent):void {

        gotoAndStop("overview");

        myBackList.push("overview");

        trace(myBackList)

    }

     

    function gotoCommemoration(event:MouseEvent):void {

        gotoAndStop("commemorationFrame");

        myBackList.push("commemorationFrame");

        trace(myBackList)

    }

     

    function gotoAboutTheLesson(event:MouseEvent):void {

        gotoAndStop("aboutTheLesson");

        myBackList.push("aboutTheLesson");

        trace(myBackList)

     

    }

     

     

    function goBack(e:MouseEvent):void {

        trace(myBackList);

        var frameGo:String=myBackList.pop();

        (currentLabel==frameGo)?gotoAndStop(myBackList.pop()):gotoAndStop(fra meGo);

        trace(myBackList);

        trace("---------");

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points