PDA

View Full Version : loadMovie + variable problemo



kingofnukes
October 23rd, 2005, 01:33 PM
Hi. I'm having trouble using variables to determine which movie my script is to load on a site I'm coding. Can someone take a look at this and tell me what's wrong? I've check my variable determining buttons already so I know that's not the problem.
//telling timeline to stop//
////
stop();
////
//telling the MC to go to a certain frame based on the selected movie//
if (_global.swf=1, 2, 3, 4, 5, 8) {
gotoAndStop(1);
} else {
gotoAndStop(2);
}
////
//telling which movie to load and in what section based on the swf variable//
//Grouping 1 : 550x400//
if (_global.swf=1) {
load1.loadMovie("http://lightning-1.com/11waystodie.swf");
gotoAndStop(1);
}
if (_global.swf=2) {
load1.loadMovie("http://lightning-1.com/Agent16.swf");
gotoAndStop(1);
}
if (_global.swf=3) {
load1.loadMovie("http://lightning-1.com/GirDance.swf");
gotoAndStop(1);
}
if (_global.swf=4) {
load1.loadMovie("http://lightning-1.com/S vs 2.swf");
gotoAndStop(1);
}
if (_global.swf=5) {
load1.loadMovie("http://lightning-1.com/SEGA FIGHT.swf");
gotoAndStop(1);
}
if (_global.swf=8) {
load1.loadMovie("http://lightning-1.com/space.swf");
gotoAndStop(1);
}
//Grouping 2 : 445x275 //
if (_global.swf=6) {
load2.loadMovie("http://lightning-1.com/stpat'sday.swf");
gotoAndStop(2);
}
if (_global.swf=7) {
load2.loadMovie("http://lightning-1.com/v day.swf");
gotoAndStop(2);
}

Adam
October 23rd, 2005, 02:52 PM
First thing that popped out was using "=" in your if statements instead of "==" Two equal signs checks equality.

Barn
October 24th, 2005, 12:01 AM
And this:


if (_global.swf=1, 2, 3, 4, 5, 8) {


...is not a valid conditional. The syntax is invalid on two counts -- one is for the assignment operator instead of equality comparison, as noted in the previous reply, and the other is that an operator must be used for EACH condition -- they cannot be conjuncted, as you have done, with commas.

And if it's a global variable, you don't need to preface the access with _global unless there is a conflicting local variable by the same name.


if (swf==1 || swf==2 || swf==3 || swf==4 || swf==5 || swf==8) {
//

And better still, for this particular case (no pun intended) would be to use a switch statement (see switch in the actionscript reference).