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

flash actionscript

group:

Runing an If Statement Multiple times


Runing an If Statement Multiple times Mr.Mini
4/8/2006 9:54:35 PM
flash actionscript:
Hello,

I'm am (trying...) to create a game and I've run into a problem with the
health which I have yet to sole :( Once health is <= 0 I want it to goto the
scene "gameOver" but the methods I've tryed have not worked.

I've tryed...



if (_root.health<=0) {
gotoAndStop("gameOver");
}

//only ran once so once health had reached zero it didn't do anything

while (_root.health >= 1) {
if (_root.health<=0) {
gotoAndStop("gameOver");
}
}

//crashed flash...

do {
if (_root.health<=0) {
_root.hair = "longponytailB";
gotoAndStop("gameOver");
}
} while (_root.health>=1);

//crashed flash

//Below code was place in two frame looping movie clip

if (_root.health <= 0) {
_parent.gotoAndStop(2);
}

//Really hoped that one worked but it didn't :( tryed it with _root. too
Re: Runing an If Statement Multiple times Star Tail Pro
4/8/2006 10:37:00 PM
I am hopping i can help cause this happen to me. What u need to do is create
function that will that will be accessed everytime the health goes down. The
function checks if the health is 0.
I would like to add becareful with while, if not used correctly flash goes
mad. with while u should use <= becaus efor some odd reason everytime I use >=
it says undefined or crashed( I think, it is just suggestion but the function
will be easier) :)
Re: Runing an If Statement Multiple times Mr.Mini
4/8/2006 10:44:47 PM
Thank you Very Very Much. I was close to insanity lol =D
Re: Runing an If Statement Multiple times Stan Vassilev
4/9/2006 1:07:16 AM
if you start a for/white cycle it won't let anything else run so it'll lock
flash, you were closer to the "truth" with the frame loops.

here's what you can do:

onEnterFrame = function () {
if (_root.health<=0) _root.gotoAndStop("label");
}

where "label" is a frame label pointing to the location to go to (for
example the first frame in your gameOver scene);

Regards, Stan Vassilev
www.flashbeyond.com -->

[quoted text, click to view]

AddThis Social Bookmark Button