all groups > flash actionscript > april 2005 >
You're in the

flash actionscript

group:

if statement doesn't terminate


if statement doesn't terminate LSmith4285
4/27/2005 12:00:00 AM
flash actionscript: Sorry about all the posts on here recently....my honours project is due on
friday :(

anyway, my latest problem is I have a long if, else if, else if ...... else
statement which monitors the location of the counter on my board game.

My problem is it doesn't terminate, for example when it goes to the following
line of code

else gotoAndPlay("difficulty", 1);

it does go there, however i see the tracers coming up from the original if
statement....i am very confused, i thought this should terminate once a
suitable result is found.

cheers
Re: if statement doesn't terminate NSurveyor
4/27/2005 12:00:00 AM
Re: if statement doesn't terminate Jeckyl
4/27/2005 12:00:00 AM
gotoAndPlay is simply a function call that sets the value for the next frame
to play (when all the script here finishes) and after it sets those values
it returns (like all function do) and your script continues. It does not,
and should not, make the script finish at that point.
--
Jeckyl

Re: if statement doesn't terminate Jon Moyles
4/28/2005 12:00:00 AM
Re: if statement doesn't terminate LSmith4285
4/28/2005 12:00:00 AM
heres the code from the scene

timetoplay = _root.gspaces * 1000;
toadd = _root.gspaces *12;
_root.goldpos = toadd + _root.goldpos;
check = _root.goldpos;
gamestart = _root.trapstart;

play ();
var id = setInterval (function () {
stop ();
clearInterval (id);
}, timetoplay);
trace("Stage 1");

pauseInt=setInterval(pauseFra,1000);
trace("Stage 2");
function pauseFra(){
trace("Stage 3");
clearIinterval(pauseInt);
trace("Stage 4");

if (check == 25){
gotoAndPlay("game", gamestart);
}

else if (check == 49){
gotoAndPlay("game", gamestart);
}

else if (check == 61){
_root.goldpos = _root.goldpos + 84;
gotoAndPlay("difficulty", 1);
}
else if (check == 73){
gotoAndPlay("game", gamestart);
trace("Stage 6");
}
else if (check == 85){
_root.goldpos = _root.goldpos - 48;
gotoAndPlay("difficulty", 1);
}
else if (check == 97){
gotoAndPlay("game", gamestart);
}
else if (check == 121){
_root.goldpos = _root.goldpos + 48;
gotoAndPlay("difficulty", 1);
}
else if (check == 145){
gotoAndPlay("game", gamestart);
}
else if (check == 157){
_root.goldpos = 0;
gotoAndPlay("difficulty", 1);
}
else if (check == 169){
gotoAndPlay("game", gamestart);
}
else if (check == 181){
_root.goldpos = _root.goldpos - 72;
gotoAndPlay("difficulty", 1);
}
else if (check == 193){
gotoAndPlay("game", gamestart);
}
else if (check == 241){
gotoAndPlay("game", gamestart);
}
else if (check == 265){
gotoAndPlay("game", gamestart);
}
else if (check == 289){
gotoAndPlay("game", gamestart);
}
else if (check == 301){
_root.goldpos = _root.goldpos + 12;
gotoAndPlay("difficulty", 1);
}
else if (check == 313){
gotoAndPlay("game", gamestart);
}
else if (check == 325){
_root.goldpos = 253;
gotoAndPlay("difficulty", 1);

}
else if (check == 337){
gotoAndPlay("game", gamestart);
}
else if (check == 361){
_root.goldpos = 529;
gotoAndPlay("difficulty", 1);
}
else if (check == 385){
gotoAndPlay("game", gamestart);
}
else if (check == 397){
_root.goldpos = _root.goldpos - 24;
gotoAndPlay("difficulty", 1);
}
else if (check == 409){
gotoAndPlay("game", gamestart);
}
else if (check == 433){
gotoAndPlay("game", gamestart);
}
else if (check == 457){
gotoAndPlay("game", gamestart);
}
else if (check == 469){
_root.goldpos = _root.goldpos - 48;
gotoAndPlay("difficulty", 1);
}
else if (check == 481){
gotoAndPlay("game", gamestart);
}
else if (check == 505){
gotoAndPlay("game", gamestart);
}
else if (check == 517){
_root.goldpos = _root.goldpos + 72;
gotoAndPlay("difficulty", 1);
}
else if (check == 529){
gotoAndPlay("hard question", 1)
}
else if (check == 553){
gotoAndPlay("game", gamestart);
}
else if (check == 577){
gotoAndPlay("game", gamestart);
}

else gotoAndPlay("difficulty", 1);
}


Now even when it does the else gotoAndPlay("difficulty", 1); line of code it
goes back up to the trace "Stage 3" and goes again.

Basically it loas diifficulty, 1 then starts going off to over screens and
jumps all over the place, even with a break; at the bottom.



I thought this should do the go to and stop running
Re: if statement doesn't terminate Flashkernel
4/28/2005 12:00:00 AM
I think you copy and pasted the same code.
If it is so you are one more victim of spelling mistake.
check this.

pauseInt=setInterval(pauseFra,1000);
trace("Stage 2");
function pauseFra(){
trace("Stage 3");
clearIinterval(pauseInt);// spelling of clearInterval incorrect
trace("Stage 4");


Re: if statement doesn't terminate LSmith4285
4/28/2005 12:00:00 AM
Cheers mate, i never spotted that!

Right its working more now....it doesn't loop on the if statement, but when it
loads up "difficulty", 1 it waits about a second then loads another page which
isn't in the if statement and I have no idea why its doing this.

Basicaly it loads up difficulty before it gets to this if statement and it
runs fine first time then once this has run it won't stop on the difficulty
page :s
Re: if statement doesn't terminate NSurveyor
4/28/2005 12:00:00 AM
Well, in your setInterval, the interval is 1000 ms or a second. So then after
one second it goes through the if statements, which creates the delay. You
could decrease the interval to about 10 and then the delay won't be that
noticeable.
Re: if statement doesn't terminate mandingo
4/28/2005 12:00:00 AM
Re: if statement doesn't terminate LSmith4285
4/28/2005 12:00:00 AM
I want it to pause before the first time it executes the if statement.

Re: if statement doesn't terminate LSmith4285
4/29/2005 12:00:00 AM
Can anyone help? this is my fianl year project at uni and its due in just 4 hours!

AddThis Social Bookmark Button