is the a script to create a back button

hi
is there a script to acheive the following

when a button is clicked the user is sent back to the scene they arrived from
this is not necessarily the prevScene

thanks in advance
liseperu
liseperuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sokhodomCommented:
Do you mean this:
attach this action to the button:

on(release) {
      gotoAndPlay("Scene 3",1);
}

Where Scene 3 is just a name of your scene.
Or you mean like " we dont know which scene the user come from" and we want to detect where he comes from and then go to that scene?

0
liseperuAuthor Commented:
the latter
i want to detect where they came from
and send back when the button is pressed - if poss

thanks
0
sokhodomCommented:
Hi, if you want the later one you should implement the flash version of COokies call SharedObject. Okay, i've test out and it work. You can view it here:
http://www.ntu.edu.sg/home2001/n0069866/scence.swf and http://www.ntu.edu.sg/home2001/n0069866/scence.fla

Here i have 4 scence. To test it, you click on the button on the first scence. it will let you to scence 3. In scence 3, i have 2 buttons, one for go back to previous scene i.e scene 1 and the other one is to go somewhere else , in this case scence 4.
So all in all, scence 2 was not into play.

Alittle note one shareobject. ShareObject inside flash is similare to implementing cookie. waht is does is to remember the user data. We can use ShareObject such as when user fill in the form etc.. You can view the tutorial here as well : http://www.kirupa.com/developer/actionscript/shared_objects.htm.

Cheers :)
SokhodoM
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

blue-genieCommented:
a quick and nasty solution

when u navigate (ie. click next ) - add that scene i.e current scene to an array, then when you click the back button, check which is second last item in array - and navigate there.

blu.
0
liseperuAuthor Commented:
hi
i likes blus thinking will give it a go and let you know
thanks
0
liseperuAuthor Commented:
do you knwo the code to capture the current scene?
0
blue-genieCommented:
when you press next, you're telling it to go to a particular scene right?

so put that in as you're going there. that would be the easiest way.
0
sokhodomCommented:
to capture the current scene, you also can use ShareObject.
You place the shareobject variables "which also include the scence variable" in each scene and when u want to check which scence you came from just retrieve that variable..
Ya.. what i like about Flash is that it has many way to move around the problem.. haha..
Cheers :)
SokhodoM
0
liseperuAuthor Commented:
hi sokho
i get it now
will give it a go and let you know how i get on
thanks
liseperu
0
liseperuAuthor Commented:
ok

the button i have created is storing the correct values but is not going to the scene when click

i have three bits of code

//global code in an include file
user = SharedObject.getLocal("visit");
user.data.name = "visited";
var backbutton:Array = [];
bbpos =0; //back button position counter

//the code that is intiated on the first frame of the scene
//code to store data for back buttons
user.data.scene = "Scene 2"
//put the current scene on the array
backbutton.push([user.data.scene]);
//increment the array back button position
bbpos++;
trace(bbpos);

// the code that is called when the button is pressed
on (release) {
      if (user.data.name == "visited")
      {
      bbpos--;
      trace(bbpos);
      trace(backbutton[bbpos]);
      gotoAndStop("backbutton[bbpos]",1);
      }
}

--------------------------------------------------------------

the output window indicates that when the button is pressed all the data that should be there is there

------->out put window<------------
0               //array position
Scene 1     //data in array at that position
------->------------------<------------

but the scene doesnt change and the array then becomes silly with negative nmbers and undefined variables

any ideas?

liseperu
0
sokhodomCommented:
May i know where you put your include files?
0
liseperuAuthor Commented:
the include file goes on the first frame of the first scene
the back button is used on the second scene
and will be used on all scenes excpet the first when i get it working

thanks
0
sokhodomCommented:
wa... I've figuere out... (on my pc) :)

Try this,
instead of gotoAndStop(...) put gotoAndPlay(); for example:
// the code that is called when the button is pressed
on (release) {
     if (user.data.name == "visited")
     {
     bbpos--;
     trace(bbpos);
     trace(backbutton[bbpos]);
     gotoAndPlay("backbutton[bbpos]",1);   ////////// here is what needed to be changed... try..:)
     }
}
cheers.
SokhodoM
0
liseperuAuthor Commented:
ok
this is driving me mad
yours works mine doesnt
i have now basically copied all your code over mine
taken it out of the actionscript includes

and i have tested that a noremal gotoAndPlay works - which it does

i almost out of ideas
and and randonly just changing things round to see if anything works

nothing seems to be working
even though the output wind is displaying all the expected data
:(
liseperu

0
liseperuAuthor Commented:
the output window is below

the first scene is Scene 1
the position of the array is 0
_______________________
posistion of array is    1
this is    Scene 2
________
now the position of array is 0
The scene to be played is Scene 1
___________
posistion of array is    1
this is    Scene 2
________

>>>>>>>>>>>>>>>>>>>>>>>>>>>
as you can see it is getting all the correct data
only it is not moving going to the scene
instead it reloads the current page

any ideas?
0
sokhodomCommented:
liseperu, I wonder if you could share that part of your .fla so that i could take a look?
In fact, it works in mine..
0
liseperuAuthor Commented:
sure
this is my email liseperu@netscape.net
if you send me a blankie i will reply with the fla attached (500k)
thanks
0
sokhodomCommented:
Hi there,
Ya the solution is like this:


1- Put this inside your backbutton except backbutton on first Scene

on (release) {
      if (user.data.name == "visited") {

      _root.gotoAndStop(backbutton[bbpos-2]);          
}
Notes here that it's minus 2 instead of bbpos and i didn't implement the bbpos--. My reason is that i will add ALL the Scene Frame name to the Array and will call the last two element. it's two element, bcoz i've implement the bbpos++ in the main frame. see section 3 and 4.

2. Put this on First Scene:
on (release) {
      if (user.data.name == "visited") {

            _root.gotoAndStop(backbutton[bbpos-1]);
      }
}
Note that here is minus one.
3. On first Scene on separate frame type this:

user = SharedObject.getLocal("visit");
user.data.name = "visited";
var backbutton = [];
bbpos = 0;

user.data.scene = "Scene 1";
backbutton.push([user.data.scene]);
bbpos++;

Note that it's bbpos++ AFTER inserting the element to array
4. On First FRame of OTHER scence put this on separate frame:

user.data.scene = "Scene 2";   <--- change the Scene 2 to other frame name.
backbutton.push([user.data.scene]);

bbpos++;

Note here that bbpos++ is after inserting element to array.
Okay, here you would know why i put bbpos-2 instead of bbpos-1 mention in number 2.
5. Finally test and run. It should be okay.

Cheers :)
SokhodoM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
liseperuAuthor Commented:
thank you mate
i have increased the points
as i was 110% happy with the answer and the time it took to help

cheers
liseperu
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.