Variable Passing

Hey,

I have used the kirupa tutorial for passing variables to a flash file, which in theory all makes sense, however my code only appears to partially work… this if from frame 1 of the movie:

if (movie=="" or movie==1) {
_root.section = “image1.swf”;
}if (movie==2) {
_root.section = “image2.swf”;
}if (movie==3) {
_root.section = “image3.swf”;
}else {
_root.section = “intro2.swf”;
}

It’ll load image3.swf if i use myfile.swf?movie=3 but any other variables will result in the else running (even no value). Any idea what is going on here?

Cheers,
dft.

Ok, some changes…

I removed the else, and now image1.swf will load, but still not image2 (image3 still works). It auto loads the intro2.swf, even without knowing where it is.

I think I need to play with this some more :slight_smile:

fixed it. haha, go team me. code is below.

if (movie==1) {
_root.section = “image1.swf”;
}if (movie==2) {
_root.section = “image2.swf”;
}if (movie==3) {
_root.section = “image3.swf”;
}else if (movie==null){
_root.section = “intro2.swf”;
}

how about a more streamlined approach?

if (movie != null) {
_root.section = “image”+movie+".swf";
}
else {
_root.section = intro2.swf;
}

btw in the long run, a relative reference is a lot more efficient than an absolute, so ie. _parent._parent.section (or whatever) instead of _root.section

ahh, nice… that’s cool. Thankyou.

can u please post the tutorial url i need it urgent

http://www.kirupa.com/developer/actionscript/tricks/passingvariables.htm