Skip to main content
Inspiring
January 30, 2019
Answered

Go to previous frame

  • January 30, 2019
  • 2 replies
  • 1929 views

Hi!

I am wondering if there is a way of pressing a button in a frame and go to previous frame played. I mean I can reach to that frame from deferents frames, and want to go back to the same frame I was before. Can you understand me?... or help?

Thank you very much.

Ana B

    This topic has been closed for replies.
    Correct answer kdmemory

    Thank you, I will try that...


    Hi anab

    it depends a little. Your desciptions sound like that all frames you navigate to are on one timeline. If that's the case then declare a variable in an Actions layer on frame 1:

    var thePreviousFrame:int;

    Now on every frame where you have a shortcut to your credits page (a button) with some actionscript like:

    CREDITSBUTTON.addEventListener(MouseEvent.CLICK, CREDITSBUTTONHandler);

    function CREDITSBUTTONHandler (e:MouseEvent) {

        thePreviousFrame = currentFrame;  

        gotoAndStop("credits");

    }

    On your credits page for the interactive element (button) to go back to previous page:

    PREVIOUSBUTTON.addEventListener(MouseEvent.CLICK, PREVIOUSBUTTONHandler);

    function PREVIOUSBUTTONHandler (e:MouseEvent) {

         gotoAndStop(thePreviousFrame);

    }

    (CREDITSBUTTON and PREVIOUSBUTTON are of course just placeholders for your instance names of those particular interactive elements.)

    Klaus

    2 replies

    ATGBAuthor
    Inspiring
    January 30, 2019

    Thank you for your answer resdesign.

    No, I mean realize it with code, AS3.

    I have frame with credits and almost all pages have a shortcut to the credits. I would like to go back to the same page, like a go to previous frame but previous frame played.

    avid_body16B8
    Legend
    January 30, 2019

    I do not code AS3 but I would assume you could use a variable to know where you are and go where you want.

    For example.

    var current;

    then you could set the variable to where you are, for example on page 1 set currrent to 1, on page 2 set current to 2, and so on.

    //for page 1

    current = 1;

    Now on your credit page, check the value of the variable.

    if (current == 1){

      // go to page that has current = 1;

          this.gotoAndPlay("page1");

    }

    and so on.

    ATGBAuthor
    Inspiring
    January 30, 2019

    Thank you, I will try that...

    avid_body16B8
    Legend
    January 30, 2019
    1. Do you mean inside ANCC timeline with a shortcut or you are talking about what you want to realize in code?
    2. ANCC AS3 or HTML5?