Using variables as scene name in gotoAndPlay

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.

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.

:-\

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 :wink:

Cheers,
Phil.

Sorry, cant help you man :wink:

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.

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

I prefer using external swf’s :wink:

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.

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.

OK OK - so for some reason which nobody seems to want to share, Scenes are naughty :wink: 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 :wink: )

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