# Back-button

**URL:** <https://forum.kirupa.com/t/back-button/2542>\
**Category:** Uncategorized\
**Created:** [June 7, 2002, 8:48am UTC](https://forum.kirupa.com/t/back-button/2542 "2002-06-07T08:48:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 7, 2002, 8:48am UTC](https://forum.kirupa.com/t/back-button/2542/1 "2002-06-07T08:48:44Z")

</div>

Hi!\r\rWhat is the command to jump to the last frame of the previous scene.E.g.: I have three scenes: sceneA, sceneB and sceneC. An element of the last frame of each scene links to sceneZ. Now I want a button in sceneZ that links either to sceneA, sceneB or sceneC depending on where I came from.\rIdeas?\rprevScene() or prevFrame() doesn’t work. I jump to another Scene and I don’t know why.\r\rTHX\r\rHartwig

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 7, 2002, 11:57am UTC](https://forum.kirupa.com/t/back-button/2542/2 "2002-06-07T11:57:08Z")

</div>

have the button code be:\r\ron(press){\rgotoAndPlay(Scene #, “SceneLabel”)\r}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 7, 2002, 12:54pm UTC](https://forum.kirupa.com/t/back-button/2542/3 "2002-06-07T12:54:54Z")

</div>

? What is SceneLabel? And: I cant’t enter a concrete # because the number depends on the scene which I’m coming from. This is each time another one\r\rH.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 7, 2002, 5:08pm UTC](https://forum.kirupa.com/t/back-button/2542/4 "2002-06-07T17:08:17Z")

</div>

Save the name of the scene with the button :

```auto
 on (press) {\r\r // go there\r\r _root.sceneNum = 3 ;\r\r}

```

Then you can use that number (I guess…)\r\rpom 0]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 8, 2002, 11:26am UTC](https://forum.kirupa.com/t/back-button/2542/5 "2002-06-08T11:26:15Z")

</div>

-previous scene links only to the scene just before in your scene panel\r-previous frame only goes back one frame\r-all scenes are considered part of the main timeline by Flash, and the frames are continuously numbered internally (ie last frame of scene one is 20, then 1st frame of scene two is 21)\r-you need to use a variable remembering the place you come from, so you can send the playhead back there:\r if you use buttons in your 3 scenes to reach scene z, in the on(release) of each, set the variable; like btn1: place=one; btn2: place=two… where place is the name of the variable, and one, two are the values you’re going to use in your goto actions in scene z\r then in scene z, supposing you got a “back” btn, action= on(release){gotoAndStop[place];} //you need to evaluate the variable, so as to use it’s value and not it’s name, else flash will try to goto a label named “place”…\r and of course, you need to put the labels (one, two,…) in the frames you want to go back to…\rI hope this works… 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 12, 2002, 7:17am UTC](https://forum.kirupa.com/t/back-button/2542/6 "2002-06-12T07:17:50Z")

</div>

Nope! unfortunately it doesn’t work. The variable is assigned the right value, but gotoAndStop[place] doesn’t work. Even I click on the right mousebutton and select back the playhead jumps to a scene I’ve never been previously.\rWhat did you mean with “evaluate the variable”? Is it the []?\rIn the frames I want to go back to I wrote: place=one;\rplace=two; …\r\rHartwig

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 12, 2002, 11:50am UTC](https://forum.kirupa.com/t/back-button/2542/7 "2002-06-12T11:50:47Z")

</div>

try this:\r\ron the first frame of the main timeline, set your variable.\r\rvar thelastscene=1; //this would equal sceneA (in my world).\r\rthen when you execute the code of sceneA, you can…\r\r\_root.thelastscene=1;\r\rsceneB\r\r\_root.thelastscene=2;\r\rsceneC\r\r\_root.thelastscene=3;\r\r\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\rNow, in Scene Z you may have a button.\r\ron(release){ //go back to the previous scene\r\r if(\_root.thelastscene==1){\r gotoandplay(“sceneA”,framenumber);\r} else if (\_root.thelastscene==2){\r gotoandplay(“sceneB”,framenumber);\r} else {\r\r (\_root.thelastscene==1){\r gotoandplay(“sceneA”,framenumber);\r}\r}\r\rMaybe?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 12, 2002, 2:17pm UTC](https://forum.kirupa.com/t/back-button/2542/8 "2002-06-12T14:17:51Z")

</div>

Yes, I solved it that way. But in the last else-loop write\r\r} else {\r\r(\_root.thelastscene==3){\rgotoandplay(“sceneC”,framenumber);\r}\r\rTHX\r\rHartwig\r

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 12, 2002, 5:45pm UTC](https://forum.kirupa.com/t/back-button/2542/9 "2002-06-12T17:45:16Z")

</div>

ahem… um … ahem… the copy and paste thing did me in. I’m glad it worked for you.\r\r
