Copy link to clipboard
Copied
Below I have attached a picture that describes what I am talking about. I have a predicament with my project as I have quite a few scenes now and was hoping there was a simple fix/cleaner way to accomplish the task.
You could have a function in each scene that stored the frame and scene that you had come from. In Scene A for example you might have a button that when you click on it you would go to Scene 2. The script would be like this (the button is named 'testbtn' for my example):
import flash.events.MouseEvent;
testbtn.addEventListener(MouseEvent.CLICK, gootherscene);
stop();
function gootherscene(e: MouseEvent) {
testbtn.removeEventListener(MouseEvent.CLICK, gootherscene);
var f: int = currentFrame;
var
...Copy link to clipboard
Copied
You could have a function in each scene that stored the frame and scene that you had come from. In Scene A for example you might have a button that when you click on it you would go to Scene 2. The script would be like this (the button is named 'testbtn' for my example):
import flash.events.MouseEvent;
testbtn.addEventListener(MouseEvent.CLICK, gootherscene);
stop();
function gootherscene(e: MouseEvent) {
testbtn.removeEventListener(MouseEvent.CLICK, gootherscene);
var f: int = currentFrame;
var s: String = "Scene A";
gotoAndStop(1, "Scene 2");
setreturn(f, s)
}
That function would take you over to Scene 2, and it would call a function 'setreturn', to make a note of where you came from.
In Scene 2 (and all other scenes) you would have this script:
import flash.events.MouseEvent;
var returnscene:String;
var returnframe:int;
returnbtn.addEventListener(MouseEvent.CLICK,doreturn);
function setreturn(framenumber:int,scenename:String){
returnframe = framenumber;
returnscene = scenename;
}
function doreturn(e:MouseEvent){
returnbtn.removeEventListener(MouseEvent.CLICK,doreturn);
gotoAndStop(returnframe,returnscene);
}
When the return button (named 'returnbtn' in my example) is clicked, it would go back to the frame and scene that you had come from.
Copy link to clipboard
Copied
Thank you Colin for this answer, it seems to work perfectly! Hopefully I will be able to better organize my animate file because of this seemingly easy function!
Copy link to clipboard
Copied
Glad it worked out ok!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now