What's wrong with my script?

i have a variable declared elswhere called floor. when this button is pressed i want 1 to be added to floor and then i want flash to go to the frame label that corresponds to the variable floor


on(press){
	_root.floor+=1;
	_root.map.gotoAndStop("_root.floor");
}

thx

Well _root.floor is a number you are declaring not a frame label. You only use double quotes " " on gotoAnds if you are targeting a frame label. So you should do this…

on(press){
	_root.floor++;
	_root.map.gotoAndStop(_root.floor);
}

I changed _root.floor+=1 to _root.floor++ because well… it is the same thing ;)…lol.

i am targeting a frame label … not a frame number

_root.floor is a number and that number is a frame label in a movieclip. i made them labels so i could move the actual frame number around.

does that make sense?

OHH!!! 'DOH I read it wrong again.

my Apologies.

Alright so in that case…

Since you are going gotoAndStop("_root.floor") it is looking for the frame label that says _root.floor. You don’t have that. What you will need to do is this…

gotoAndStop("""+_root.floor+""");

" is how to add a double quote inside double quotes (I believe that is right) So this will make your final output like this (if _root.floor outputs 5)…

gotoAndStop(“5”);

doesn’t work … what’s with the +'s

here’s the error i get

Scene=main, Layer=buttons, Frame=1: Line 3: ‘)’ or ‘,’ expected
_root.map.gotoAndStop(gotoAndStop(“"”+_root.floor+“"”);

you put a gotoAndStop inside a gotoAndStop?

I meant to replace the gotoAndStop with the new one… so it will be…

_root.map.gotoAndStop("""+_root.floor+""");

The + attaches (old usage used to be “add”) the next thing to the string, so if _root.floor it would of outputted 5, it would be like this…

" + 5 + "

Combining them to become “5”

hahahahahaha … stupid copy/paste error

still doesn’t work though

the file is 2.3mb do you have an email addy where i can send it to you so maybe you can see what i’m trying to do?

No, my inbox is almost full, I can’t have that big of a file.

Can you upload it to a server?

I don’t see why it doesn’t work though… in a new document try this…

Paste these actions on Frame 1

floor = 5;
a = "gotoAndStop("+"\""+_root.floor+"\""+")";
trace(a);

It outputs the right syntax.

Maybe I should have testing what I was saying before I gave you the code though :-\

actually i uploaded it to a server
www.roughedout.com/tour.abc

download and change the extension to fla
it should work

the button i’m working on is on the buttons layer and it’s the one that looks like stairs with the + above it. i will obviously be doing the - next.

thx

also if you are just feeling industrius or otherwise bored you are more than welcome to make suggestions on other parts of this program i’ve been working on for way too long =)

Well what I am wondering are two things…

I can’t seem to find any movie clip with the instance name “map”.

I assumed it was the big clip in the middle, but that is a graphic symbol.

Also… why do it by a variable? Why not just use _root.map.nextFrame() ?

Nevermind… got it…lol.

And yes… _root.map.nextFrame() works.

So for the minus one you cna use _root.map.prevFrame()

in the layers there is a folder of layers called map … the symbol is in there … if you look in the library the symbol itself is called mapview.

and i don’t use nextframe b/c there are many other things inside that symbol, all the divisions of the company (selectable through the combobox) so they won’t always be right next to the proper frame.

that button is only to go between floors on the map … not through every frame of the mc. that would take them through all the divisions etc which i want them to select via the combobox

once you open the symbol you should be able to see what i’m talking about

LOL… man you gotta be difficult dontcha!.. :beam:

Well I can’t work on it right now, I am about to go soon, and your file keeps crashing my Flash whenever I try to edit something or preview it.

Hopefully someone else will be able to solve it, if not, I will be back on it when I come back later.

ok … thanks for the help

someone help me!

:trout: stupid project is whoopin me

Hey shuga, I can’t work on it today (going to see my girlfriend… YAY), but I found this excellent article at Macromedia that seems like it may fix your problem…

http://www.macromedia.com/support/flash/ts/documents/flash_labels_scripting.htm

Note: Yes, it was written for Flash for, so some syntax needs updating in it, but the basic idea is still there.

according to the article

In this example, note the use of quotes to indicate the movie clip’s instance name as a string, to which the variable’s value is concatenated:

Go to and Play (“/theClip:” & theVariable)

my script should read


on(press){
	floor++;
	trace(floor);
	gotoAndStop("_root.map:"&floor);
}

and it might work … i dunno … i don’t think my variable is being detected b/c the trace action doesn’t even work. it does the same thing if i put _root in front of floor as well

not really sure what’s wrong

_root.map.gotoAndStop(string(_root.floor))

Hmm, odd… ++ is used to increment a variable, but if used here, it doesn’t read the variable at all.

This traces fine

on (press) {
	floor += 1;
	trace(floor);
	gotoAndStop("_root.map:" & floor);
}

Hmm, didn’t know you could do that Senocular… interesting… ;)…lol.