Copy link to clipboard
Copied
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?
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.)
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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."
Copy link to clipboard
Copied
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.)
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now