0
Back button in AS3
Explorer
,
/t5/animate-discussions/back-button-in-as3/td-p/791887
Feb 03, 2009
Feb 03, 2009
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
frame visited from any frame in the site. There are various buttons
to get to various frames, and the one back button will always be
showing.
What's the script to make that happen from any frame utilizing AS3?
What's the script to make that happen from any frame utilizing AS3?
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/animate-discussions/back-button-in-as3/m-p/791888#M17108
Feb 03, 2009
Feb 03, 2009
Copy link to clipboard
Copied
1. label every frame that you want it to be able to go back
to
e.g. page1, page2 etc
2. create a single variable to be used throughout your flash file
e.g: var backValue:String;
3. on each frame you have labeled reset the variable value to whatever the frame label is
backValue = "whatever the frame label is";
4. on your back button make it go back to the value of your variable
back.addEventListener(MouseEvent.CLICK, backFunction);
function backFunction(e:MouseEvent):void {
gotoAndStop(backValue);
}
this will only work for one page, youl have to use a array or series of variables to create a proper history
e.g. page1, page2 etc
2. create a single variable to be used throughout your flash file
e.g: var backValue:String;
3. on each frame you have labeled reset the variable value to whatever the frame label is
backValue = "whatever the frame label is";
4. on your back button make it go back to the value of your variable
back.addEventListener(MouseEvent.CLICK, backFunction);
function backFunction(e:MouseEvent):void {
gotoAndStop(backValue);
}
this will only work for one page, youl have to use a array or series of variables to create a proper history
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Online_in_Oregon
AUTHOR
Explorer
,
/t5/animate-discussions/back-button-in-as3/m-p/791889#M17109
Feb 03, 2009
Feb 03, 2009
Copy link to clipboard
Copied
Thank you so much for your help. I've tried that and am
getting this error:
ArgumentError: Error #2109: Frame label null not found in scene Scene 1.
at flash.display::MovieClip/gotoAndStop()
at berylstonemain2_fla::MainTimeline/backFunction()
What might I be doing wrong? The frames are labeled and the whole site is in scene1.
I'd love to make a proper history, but think this is the less ambitious and most likely to succeed solution for now.
ArgumentError: Error #2109: Frame label null not found in scene Scene 1.
at flash.display::MovieClip/gotoAndStop()
at berylstonemain2_fla::MainTimeline/backFunction()
What might I be doing wrong? The frames are labeled and the whole site is in scene1.
I'd love to make a proper history, but think this is the less ambitious and most likely to succeed solution for now.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/animate-discussions/back-button-in-as3/m-p/791890#M17110
Feb 03, 2009
Feb 03, 2009
Copy link to clipboard
Copied
are your paths correct?
as in your not telling it to look for a label called page1 on the main timeline when its actually inside a movieclip?
as in your not telling it to look for a label called page1 on the main timeline when its actually inside a movieclip?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Online_in_Oregon
AUTHOR
Explorer
,
/t5/animate-discussions/back-button-in-as3/m-p/791891#M17111
Feb 03, 2009
Feb 03, 2009
Copy link to clipboard
Copied
Yeah, it's a pretty simple file that I'm picking up and just
editing.
So, on the first frame I have
var backValue:String;
backValue:"PageHome";
in the actionscript.
On the following frames (everything's just one main scene with frames and gotoandstops) I have, for example, the frame labeled PageAboutUs and in the actionscript window backValue:"PageAboutUs" and so on.
I'm sure there's something really basic I'm messing up here… thanks again for your help!
So, on the first frame I have
var backValue:String;
backValue:"PageHome";
in the actionscript.
On the following frames (everything's just one main scene with frames and gotoandstops) I have, for example, the frame labeled PageAboutUs and in the actionscript window backValue:"PageAboutUs" and so on.
I'm sure there's something really basic I'm messing up here… thanks again for your help!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/animate-discussions/back-button-in-as3/m-p/791892#M17112
Feb 03, 2009
Feb 03, 2009
Copy link to clipboard
Copied
its backValue="PageAboutUs";
not
backValue:"PageAboutUs";
its always a single equals sign to assign a variable
heres a simple demo switching between 2 pages
http://www.rad-media.co.uk/example.fla
not
backValue:"PageAboutUs";
its always a single equals sign to assign a variable
heres a simple demo switching between 2 pages
http://www.rad-media.co.uk/example.fla
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Online_in_Oregon
AUTHOR
Explorer
,
/t5/animate-discussions/back-button-in-as3/m-p/791893#M17113
Feb 03, 2009
Feb 03, 2009
Copy link to clipboard
Copied
OK, syntax was wrong and I fixed that (I knew it had to be
some silly error like that).
So now, if I go to one of the pages (frames), then go back to the home page (home frame), and click the back button it works to take you back to whatever subpage you were just on. However, it only works from the home page to go back to a subpage. You can't use the back button to go from one subpage to another you were just on, or back to the home page again. Why would that be? Is there a way to make the back button work from anywhere?
Also, it only works if I don't assign the home page a backvalue (probably why you can't go "back" to the home page). But, since it works to go back from there to any other page you were just on, I think it must be close to working across the board… just curious what the problem could be… help??
So now, if I go to one of the pages (frames), then go back to the home page (home frame), and click the back button it works to take you back to whatever subpage you were just on. However, it only works from the home page to go back to a subpage. You can't use the back button to go from one subpage to another you were just on, or back to the home page again. Why would that be? Is there a way to make the back button work from anywhere?
Also, it only works if I don't assign the home page a backvalue (probably why you can't go "back" to the home page). But, since it works to go back from there to any other page you were just on, I think it must be close to working across the board… just curious what the problem could be… help??
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Online_in_Oregon
AUTHOR
Explorer
,
/t5/animate-discussions/back-button-in-as3/m-p/791894#M17114
Feb 03, 2009
Feb 03, 2009
Copy link to clipboard
Copied
Would an array work to allow the back button to work
throughout the site? How would I do that?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/animate-discussions/back-button-in-as3/m-p/791895#M17115
Feb 03, 2009
Feb 03, 2009
Copy link to clipboard
Copied
it sounds like it could be 1 of 2 things.
if your buttons not working at all you havent got the script with the event listener applied to the button on that frame or your variable isnt being passed through or read on the frame its stopping on.
try using trace statements to pinpoint where the problem is
trace("this bits working");
if your buttons not working at all you havent got the script with the event listener applied to the button on that frame or your variable isnt being passed through or read on the frame its stopping on.
try using trace statements to pinpoint where the problem is
trace("this bits working");
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/animate-discussions/back-button-in-as3/m-p/791896#M17116
Feb 03, 2009
Feb 03, 2009
Copy link to clipboard
Copied
as for using arrays, all youd do is create an array and every
time you go to a new page its adds a new element storing the frame
label into the array.
when back is clicked it retrieves the previous element from the array (and deletes the top one) and goes to this page.
this way you can store as much history as yuo want aslong as you make the array long enough
have a look at this and some array tutorials and you should get an idea of what im on about
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Array.html
when back is clicked it retrieves the previous element from the array (and deletes the top one) and goes to this page.
this way you can store as much history as yuo want aslong as you make the array long enough
have a look at this and some array tutorials and you should get an idea of what im on about
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Array.html
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Online_in_Oregon
AUTHOR
Explorer
,
/t5/animate-discussions/back-button-in-as3/m-p/791897#M17117
Feb 03, 2009
Feb 03, 2009
Copy link to clipboard
Copied
Thank you, thank you ross_design. I think it's worth checking
out arrays and looking at doing it that way. I really appreciate
your time today.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/animate-discussions/back-button-in-as3/m-p/791898#M17118
Feb 03, 2009
Feb 03, 2009
Copy link to clipboard
Copied
no probs
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

