Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to reference a scene name in

Status
Not open for further replies.

carpeliam

Programmer
Mar 17, 2000
990
US
I want to reference a scene name in a variable - for instance, I want to be able to say:

gotoAndStop(mySceneString, myFrameLabel);

however, this is giving me an error, saying "Scene name must be quoted string". I tried the following:

gotoAndStop(new String(mySceneString), myFrameLabel);

but that still didn't work. Is this sort of thing possible? Otherwise, there is no way to automate this.. and the only way to get around this would be:

if (mySceneString == "scene01") gotoAndStop("scene01", myFrameLabel);

this would be highly inefficient, and it doesn't seem like Flash would make such a restriction... is there another way to go about this? Thank you for your time... Liam Morley
lmorley@gdc.wpi.edu
"light the deep, and bring silence to the world.
light the world, and bring depth to the silence."
 
Here is the code
on (release) {
gotoAndPlay("Scene 2", "test");
}
test is the lable in scene two, so I believe what it wants is to put your scene name in quotes "Scene 2". Set up your variable like that and see if it works.
 
Frame labels should be unique! Simply target that label, no need to target the scene name, which wouldn't work from within a movie clip either:

_root.gotoAndPlay("myFrameLabel"); Regards,

new.gif
 
kirbsc thanks but I did already know the code, as I showed in my post.

Thanks, oldnewbie, for your response. That was what I was afraid of;) Here's my problem. I'm making a node graph. The player can be anywhere on a two dimensional grid, with coordinates x and y.

<code>x = 5;
y = 4;</code>

each scene in flash corresponds to a node; they are named &quot;node00&quot;, &quot;node01&quot;, etc. Each node corresponds to a point on the grid:

<code>node[2][4] = &quot;node00&quot;;
node[5][4] = &quot;node01&quot;;</code>

Finally, the player can be facing east, west, south or north. These are frame labels in each individual scene. There is a direction variable that keeps track of their current direction:

<code>direction = &quot;EAST&quot;</code>

Then when a player moves, I want to say the following:

<code>gotoAndStop(node[x][y], direction)</code>

where they go to the corresponding scene facing in a particular direction. Unfortunately, for reasons I don't understand, variables can't be used for scene names.. so what it seems what I'll have to do is make frame labels global (as in your suggestion, oldnewbie), like &quot;node00WEST&quot;, &quot;node01WEST&quot;, etc. Does anyone see another solution? Could anybody tell me why only enquoted strings are acceptable? Liam Morley
lmorley@gdc.wpi.edu
&quot;light the deep, and bring silence to the world.
light the world, and bring depth to the silence.&quot;
 
Movie clip instances can be referred to with variables, using the associative array syntax.

mySceneString = &quot;Scene 2&quot;;

on (press) {
trace (_root[&quot;mySceneString&quot;]);
_root.gotoAndStop(_root[&quot;mySceneString&quot;], &quot;myFrameLabel&quot;);
}

Tried it with scene names and altough a trace action will output the correct scene name in the above, it seems that it won't work when targeting a scene name that way. So guess the unique label is your only way out. Unless I'm missing something, which is another possibility! Regards,

new.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top