Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

SCENES BACK BUTTON

New Here ,
Oct 24, 2013 Oct 24, 2013

I did a search on this and didn't find a successful answer yet.

I need to have a back button in AS3 that'll remember the last SCENE visited from any frame in the site. There are various buttons to get to various SCENES, and the one back button will always be showing.

What's the script to make that happen from any frame utilizing AS3?

TOPICS
ActionScript
589
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 24, 2013 Oct 24, 2013

you should execute the following once:

var sceneA:Array = [];

function addSceneF(scene:Scene):void{

    sceneA.push(scene);

}

function prevSceneF():void{

    sceneA.pop();

    this.gotoAndStop(1,sceneA.pop().name);

}

// then on frame 1 of each scene use:

addSceneF(this.currentScene);

and have your previous scene button call prevSceneF whenever you want to return to a previously visited scene.

(and you should do some error checking to make sure sceneA.length >0 before applying that goto.)

Translate
Community Expert ,
Oct 24, 2013 Oct 24, 2013

you'll need to track (use an array) the scenes visited.  then use the pop method twice (the first time will be the current scene) to retrieve the previously visited scene.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 24, 2013 Oct 24, 2013

Tell me more about this pop method...

I'm trying this code:

var backValue:String;

backValue ="SCENE_NAME";

function backFunction(e:MouseEvent):void {

gotoAndStop(backValue);

}

But, it isn't working... this is the error: "ArgumentError: Error #2109: Frame label SCENE_NAME not found in scene CURRENT_SCENE."

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 24, 2013 Oct 24, 2013

you should execute the following once:

var sceneA:Array = [];

function addSceneF(scene:Scene):void{

    sceneA.push(scene);

}

function prevSceneF():void{

    sceneA.pop();

    this.gotoAndStop(1,sceneA.pop().name);

}

// then on frame 1 of each scene use:

addSceneF(this.currentScene);

and have your previous scene button call prevSceneF whenever you want to return to a previously visited scene.

(and you should do some error checking to make sure sceneA.length >0 before applying that goto.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 24, 2013 Oct 24, 2013
LATEST

Trying righ now!

______________________

Now i have this error when i click on "BACK BUTTON":

ArgumentError: Error #1063: Argument count mismatch on TESTE/prevSceneF(). Expected 0, got 1.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines