If then

if i have a dynamic text box with a var = lives
how can i make it so that if lives < 1 then gotoAndStop(2); ?

How about

if (parseInt (lives) &lt; 1) gotoAndStop (2) ;[/As]

hmm, doesn’t seem to work, and just wondering, what does parseInt mean?

Look it up in the ActionScript Dictionary! :wink:

http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary621.html

hmmm

parseInt converts a string to an integer.

The code Ilyas provided you is right. Im guessing that its not working because of the way you are checking for that statement. That if statement needs to be continually checked, using for example an onEnterFrame handler or setInterval. Something like this should work

this.onEnterFrame = function() {
	if (lives<1) {
		this.gotoAndStop(2);
		delete this.onEnterFrame;
	}
};

what if lives isn’t in a movie clip?
its on the main stage

example, this is how i am using it

Remove this line from your actions layer:

if (parseInt (_root.lives) < 1) gotoAndStop (2) ;

Then, place this line inside the onClipEvent(EnterFrame) of your enemy1 movie clip:

	if (_root.lives < 1) _root.gotoAndStop (2) ;

thanks claudio :slight_smile:
by the way, do you know why those missles are not exploding when they hit the ground?

if(this.hitTest(_root.ground) and !exploding) {
	exploding=true;
	_root.enemy+i.gotoAndPlay(2);
	_root.lives -= 1;

}

is what i have for that on the missle mc

Replace:

if(this.hitTest(_root.ground) and !exploding) {
		exploding=true;
		_root.enemy+i.gotoAndPlay(2);
		_root.lives -= 1;
}

for:

if (this.hitTest(_root.ground)) {
		gotoAndPlay(2);
		_root.lives--;
	}

i prob shouldn’t be asking so many questions, or changing the topic of the thread like this, but i have just one more…

do you know if it is possible, to limit the number of lasers you can shoot at a time to 3, until they hit the top of the screen like in that game space invaders where you have to shoot down the aliens in rows, you only get one shot until your laser hits the top…

I made a few changes. You can only shoot again if you hit an enemy or the laser gets off the screen. I didnt dig into the code to check for unnecessary code though.

wow, thats great, thanks a ton claudio :slight_smile:

Glad i could help :slight_smile: