Newbie variable question

Pardon my ignorance (i just started with flash about a month ago)but I cant seem to get a variable to work correctly… i think its just a syntax problem

Here’s the situation:
I have a button that sets a variable (called link) to a value
This button also sends the movie to a different section of the movie and plays (which works fine)
When the transport hits the end of that section, i want the movie to jump to a frame which has the same name as the variable value.

My problem is with the syntax i guess on that frame where i want the movie to jump to variable… Does this even make sense?

Perhaps there is an easier way to do this. My goal is to be able to have a series of buttons with different variable values, have the movie play this one little section and jump to the frame that is equal to the variable value.

my code:
The botton code is:
on (release) {set (link, “news”);gotoAndPlay(“in”);}
(which seems to work)

The frame that is supposed to redirect has the code:
gotoAndPlay (link);

again, sorry for the stupidity

Thank you for the reply, unfotunatly it didn’t work.

Link is the variable name, should that be in quotes still (i came from a VB background… quotes=bad…lol)
and the name of one of the frames is news

im going to try and create a dynamic text box with the var set to link and perhaps it will display the varible that is being set…

Thanks again

if link is var, no quotes allowed.

var mybuttonvalue = “somewhere”

sends it… mc.gotoandplay(mybuttonvalue);

perhaps the problem is the scope of your variable.

try using _global.mybuttonvalue = “value”;
mc.gotoandplay(mybuttonvalue);

good luck.

hey thank you , im not exactly sure what that mc is for before the gotoandplay (it seems to make the code not do anything) I think i figured out a roundabout way to do this though
i put on teh frame i wanted to redirect:
if (variable = “news”) {
then
gotoAndPlay (31);}
so basically, for all of my buttons i will have to put an addition to the if statement. This seems to work, though i would like to know if it is possible to have the frame action use a variable for direction.
Thanks again

Why not set the value of ‘link’ with a button:


on(release){
_root.link = 1;
//or whatever
}

Then on the timeline at the end of your transition, put:


gotoAndPlay(_root.link);

That way you set link to where ever you want your movie to go to, then at the transition, it will go to where ever you set ‘link’ to.

If you use the code that you just posted, you need two equal signs for the comparison in programming such as:


if (variable == "news"){
gotoAndPlay(31);
}

Good luck!!

what he said :slight_smile:

btw, mc means movieclip. In most cases, it just means use the name of the instance instead of mc. So, if you placed an instance of a circle on the stage, and you went to the properties of that instance and gave it the name “circle”, then instead of mc._x you would say circle._x

Hope that helps.

:stuck_out_tongue: Sorry, got caught up. Nice av!!! - but doesn’t look like The Princess Bride…much…:stuck_out_tongue:

Thanks for the replies, I’m gonna try that out today.
:thumb: