PDA

View Full Version : Using a variable for frame label?



JapanMan
November 7th, 2008, 03:22 PM
I'm making a game, and in between short levels, you go to a "reset" frame to prepare for the next level. I have a dynamic text box named "level" that increases by 1 every time you finish a stage. When you click the button on the "reset" frame, you go to the appropriate level's frame; the levels are labeled with just the number. So far, I have been managing this as follows:


//in the button's actions
on (release) {
if (level == 1) {
gotoAndStop("1");
}
if (level == 2) {
gotoAndStop("2")
}
}etc. etc.

I want to know if I could manage this with just one statement like

on (release) {
gotoAndStop(level);
}where "level" is the value of the dynamic text box.

Much thanks!

Krilnon
November 7th, 2008, 03:27 PM
gotoAndStop(level.toString()); ?

JapanMan
November 7th, 2008, 04:23 PM
unfortunately, that didn't work, it just re-loads the frame you're already on.

here's the .fla
48376

I'm also having a problem with hitTesting the "blobs", the red circles. If someone could look at the script for the array and its collisions, I'd appreciate it too.

Thanks.

substance
November 7th, 2008, 05:52 PM
gotoAndStop(level.toString()); ?

He gave you a solution, and according to what you posted it should work. You can try casting it, String(level);

I'm assuming this isnt AS3, because all those solutions would work...

SparK_BR
November 8th, 2008, 04:59 PM
level is a flash player variable

try giving it another name!

then gotoAndStop(otherVar); will work for sure