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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variables and gotoAndPlay

Status
Not open for further replies.

DeepBlerg

Technical User
Jan 13, 2001
224
AU
I'm using the following actionscript a few times in my movie:

gotoAndPlay(myvalue+"location");

For example:
if myvar is equal to 5. It actually goes to the frame labelled "3location". In other words, it subtracts two all by itself.

To combat this I have to do this:
gotoAndPlay((myvalue+2)+"location");

Is there an issue with vars and gotoAndPlay, am I overlooking something?
 
If you're talking framelabel, having a label start by a number is a very bad idea.
And do you happen to have a 2 frame preloader? Or some other 2 frame scene, preceding this scene you're navigating in?

Regards,

cubalibre2.gif
 
put the number at the end if you can...
then create another variable

myFrameLabel="location"+myValue;
_root.myMovieClip.gotoAndPlay(myFrameLabel);

cheers
 
oldnewbie,

Yeh I do have a 3 frame preloader in scene 1. how does this effect it?
 
Since you put a number at the beginning of your frame label, I think Flash is confused and considers that as a frame number and not a frame label. When using a goto with a frame number, most of the time, Flash sees it as a cumulative frame number, the sum of all frames in all previous scenes to the targeted frame...
So if you're targeting frame 2 of a scene 2, and your scene 1 holds 3 frames, you then have to actually target frame 5 (3+2=5), to get to the right frame. This is error prone, and if you edit any scene previous to your targeted frame, then you'll have to correct and edit all of your gotos. Much better to use a frame label (at least not starting off with a number!), since the label is allways attached to one particular frame, no matter how many edits you make in the previous scenes.

Regards,

cubalibre2.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top