# Using variables as scene name in gotoAndPlay

**URL:** <https://forum.kirupa.com/t/using-variables-as-scene-name-in-gotoandplay/24014>\
**Category:** flash\
**Created:** [June 25, 2003, 10:17am UTC](https://forum.kirupa.com/t/using-variables-as-scene-name-in-gotoandplay/24014 "2003-06-25T10:17:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![philmwebb](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@philmwebb](https://forum.kirupa.com/u/philmwebb)\
**Post date:** [June 25, 2003, 10:17am UTC](https://forum.kirupa.com/t/using-variables-as-scene-name-in-gotoandplay/24014/1 "2003-06-25T10:17:50Z")

</div>

I’m trying to create a component that will take as one of its parameters the name of a scene and will then using that name in various calls to gotoAndPlay. For instance:

```
 gotoAndPlay(mainSceneName, 1);

```

Flash is complaining about this with syntax errors saying that the “Scene name must be quoted string”

mainSceneName is defined as a String parameter for my component so I would have expected this to work OK (i.e. using a String variable rather than a String constant works fine in other programming languages!)

Anyone got any clues :q:

Thanks,  
Phil.

---

<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 25, 2003, 11:22am UTC](https://forum.kirupa.com/t/using-variables-as-scene-name-in-gotoandplay/24014/2 "2003-06-25T11:22:07Z")

</div>

Ive never done dat, and it seems pointless on my first impression of it. If u need to call scene 2, just use gotoAndPlay and select scene 2.

:-\

---

<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 25, 2003, 11:39am UTC](https://forum.kirupa.com/t/using-variables-as-scene-name-in-gotoandplay/24014/3 "2003-06-25T11:39:40Z")

</div>

Components…

I’m creating a component which will sit in the first scene and will control when/how/if at all to move to the main scene. I don’t want to prescribe to users of the component what they must call their main scene, so was hoping to make it a configurable option on the component.

Also as I was a software engineer in my former life I HATE hardcoding these things 😉

Cheers,  
Phil.

---

<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 25, 2003, 11:43am UTC](https://forum.kirupa.com/t/using-variables-as-scene-name-in-gotoandplay/24014/4 "2003-06-25T11:43:07Z")

</div>

Sorry, cant help you man 😉

---

<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 25, 2003, 11:43am UTC](https://forum.kirupa.com/t/using-variables-as-scene-name-in-gotoandplay/24014/5 "2003-06-25T11:43:44Z")

</div>

Scenes are a no-no. Bad little buggers that are a left-over from the old days.

Do you know that mainSceneName exists in that timeline? Trace it, see if it exists.

---

<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 25, 2003, 12:00pm UTC](https://forum.kirupa.com/t/using-variables-as-scene-name-in-gotoandplay/24014/6 "2003-06-25T12:00:04Z")

</div>

mainSceneName traces fine and shows me the value I’d entered on the components parameter page, but when used in gotoAndPlay it results in the syntax error, “Scene name must be quoted string”, and therefore none of my AS for that frame runs.

Your reply also begs the question: why are scenes a no-no? what’s wrong with them? what should I use instead (apart from separate swf files)?

Cheers,  
Phil

---

<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 25, 2003, 12:01pm UTC](https://forum.kirupa.com/t/using-variables-as-scene-name-in-gotoandplay/24014/7 "2003-06-25T12:01:51Z")

</div>

I prefer using external swf’s 😉

---

<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 25, 2003, 12:09pm UTC](https://forum.kirupa.com/t/using-variables-as-scene-name-in-gotoandplay/24014/8 "2003-06-25T12:09:25Z")

</div>

Well, scenes usually are used for ordening your files (preload+intro, menu, enz). You could easely use framelabels as comments, maybe even make an seperate layer for it.

Why not scenes? For one, the swf doesn’t have scenes. It just pastes everything together, thus elimenating all scenes. If you use gotoAndPlay/Stop, play() and sorts you will always need to use scenenames, because when flash fudges the scenes together, the frame count wil just rise and not start all over again with every new scene. This means that you need to add up the total frames of the previous scenes to come to the real framenumber.

Personally, i think that scenes adds anoth obstacle when going though the site. It’s much easier if you can read from a simple layer where you are.

---

<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 25, 2003, 12:12pm UTC](https://forum.kirupa.com/t/using-variables-as-scene-name-in-gotoandplay/24014/9 "2003-06-25T12:12:07Z")

</div>

And if you really want to divide your movie without using external swf’s, use movieclips. You can add so much more functionality (tweens, code, etc) than if you would use scenes.

---

<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 25, 2003, 1:51pm UTC](https://forum.kirupa.com/t/using-variables-as-scene-name-in-gotoandplay/24014/10 "2003-06-25T13:51:44Z")

</div>

OK OK - so for some reason which nobody seems to want to share, Scenes are naughty 😉 Seems to me that scenes are a logical way to divide up a show (Shakespeare seemed to like them, which is good enough for me 😉 )

But why won’t flash accept a variable as the first parameter to gotoAndPlay(scene, frame)?
