# (FMX): gotoandplay(variable) as scene

**URL:** https://forum.kirupa.com/t/fmx-gotoandplay-variable-as-scene/91838
**Category:** Uncategorized
**Created:** [October 9, 2003, 2:44pm UTC](https://forum.kirupa.com/t/fmx-gotoandplay-variable-as-scene/91838 "2003-10-09T14:44:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![pepper](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/pepper/32/344_2.png) [@pepper](https://forum.kirupa.com/u/pepper)
#### Post date: [October 9, 2003, 2:44pm UTC](https://forum.kirupa.com/t/fmx-gotoandplay-variable-as-scene/91838/1 "2003-10-09T14:44:11Z")

</div>

Hi,  
I am working on a project with several scenes and sections of frames within these scenes which act as pages.  
I have a next and back button in a movieclip. Let’s concentrate on one of them because they are similar anyway.  
When you click on next, it does a function which is set in the first frame of each scene. The function is called fNext.  
Everything is working ok up to now but in the function I need to specify where next is.  
I decided to use a variable which I set in the last frame of every page where the palayhead finally stops. For example in scene MainMenu I have 2 pages 30 frames. Page 1 (startMain) is frames 1 to 30 and page 2 (Main) is frames 31 to 60. Scene Introduction has only one page frames 1 to 30. There are about 12 scenes.  
Now when I am in scene MainMenu page 1 (startMain I set the next variable to 0 and in the functionfNext is says:

function fNext() {  
trace(“hello”);  
if (next == 0) {  
nextFrame();  
} else if (next == “stop”) {  
stop();  
} else {  
nextScene();  
}

That is working. I need to change the nextScene().  
In scene MainMenu page 2 (Main), when I click next I want to go to the next scene (Introduction) and I can do it if I just use nextScene but my boss wants me to use a variable in case the scene order is mixed up.  
That means I need an “else” that goes to the scene that is the value of the ‘next’ variable set in the page you are.  
For example next = “Introduction”  
This did not work. How can I set a variable for the scene and use gotoAndPlay(variable). If I cannotdo it is there a way round it?

I know it sounds complicated but I am greek and I don’t know how to explain it very well.

Many thanks.
