# If then

**URL:** <https://forum.kirupa.com/t/if-then/35001>\
**Category:** Uncategorized\
**Created:** [November 9, 2003, 2:26am UTC](https://forum.kirupa.com/t/if-then/35001 "2003-11-09T02:26:46Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![macneilslt](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@macneilslt](https://forum.kirupa.com/u/macneilslt)\
**Post date:** [November 9, 2003, 2:26am UTC](https://forum.kirupa.com/t/if-then/35001/1 "2003-11-09T02:26:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2003, 2:42am UTC](https://forum.kirupa.com/t/if-then/35001/2 "2003-11-09T02:42:46Z")

</div>

How about

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2003, 3:06am UTC](https://forum.kirupa.com/t/if-then/35001/3 "2003-11-09T03:06:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2003, 5:38am UTC](https://forum.kirupa.com/t/if-then/35001/4 "2003-11-09T05:38:34Z")

</div>

Look it up in the ActionScript Dictionary! 😉

[http://www.macromedia.com/support/flash/action\_scripts/actionscript\_dictionary/actionscript\_dictionary621.html](http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary621.html)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2003, 5:41am UTC](https://forum.kirupa.com/t/if-then/35001/5 "2003-11-09T05:41:08Z")

</div>

hmmm

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2003, 5:50am UTC](https://forum.kirupa.com/t/if-then/35001/6 "2003-11-09T05:50:14Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2003, 6:01am UTC](https://forum.kirupa.com/t/if-then/35001/7 "2003-11-09T06:01:57Z")

</div>

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

example, this is how i am using it

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2003, 6:08am UTC](https://forum.kirupa.com/t/if-then/35001/8 "2003-11-09T06:08:59Z")

</div>

Remove this line from your actions layer:

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

```

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

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

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2003, 6:21am UTC](https://forum.kirupa.com/t/if-then/35001/9 "2003-11-09T06:21:04Z")

</div>

thanks claudio 🙂  
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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2003, 6:25am UTC](https://forum.kirupa.com/t/if-then/35001/10 "2003-11-09T06:25:20Z")

</div>

Replace:

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

```

for:

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

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2003, 6:29am UTC](https://forum.kirupa.com/t/if-then/35001/11 "2003-11-09T06:29:50Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2003, 6:40am UTC](https://forum.kirupa.com/t/if-then/35001/12 "2003-11-09T06:40:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2003, 6:43am UTC](https://forum.kirupa.com/t/if-then/35001/13 "2003-11-09T06:43:58Z")

</div>

wow, thats great, thanks a ton claudio 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 9, 2003, 6:44am UTC](https://forum.kirupa.com/t/if-then/35001/14 "2003-11-09T06:44:42Z")

</div>

Glad i could help 🙂
