# If questions

**URL:** <https://forum.kirupa.com/t/if-questions/266071>\
**Category:** Uncategorized\
**Created:** [July 15, 2008, 11:45pm UTC](https://forum.kirupa.com/t/if-questions/266071 "2008-07-15T23:45:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![spyderfx](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@spyderfx](https://forum.kirupa.com/u/spyderfx)\
**Post date:** [July 15, 2008, 11:45pm UTC](https://forum.kirupa.com/t/if-questions/266071/1 "2008-07-15T23:45:05Z")

</div>

this doesn’t work

if (lives \<= 0) {  
gotoAndStop(22);  
}

when i change the “\<=” to something like “!=” it does work. i’m trying to make it go to a certain frame when the variable hits 0

---

<div class="post-metadata">

**Author:** ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)\
**Post date:** [July 16, 2008, 12:27am UTC](https://forum.kirupa.com/t/if-questions/266071/2 "2008-07-16T00:27:49Z")

</div>

have you assigned a value to lives before your condition statements ?

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [July 16, 2008, 1:08am UTC](https://forum.kirupa.com/t/if-questions/266071/3 "2008-07-16T01:08:45Z")

</div>

The above statement doesn’t continuously check when lives are decreased.

Try something like this;

```auto

var lives:Number = 15;

function killOneLife():Void {
  lives--;
  if (lives <= 0) gotoAndStop(22);
  else trace("lives left: "+lives);
};

killOneLife();

```

---

<div class="post-metadata">

**Author:** ![spyderfx](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@spyderfx](https://forum.kirupa.com/u/spyderfx)\
**Post date:** [July 16, 2008, 4:39am UTC](https://forum.kirupa.com/t/if-questions/266071/4 "2008-07-16T04:39:46Z")

</div>

ah thanks sekasi

two questions. what does the “void” mean. and does trace only display text on the output or does it continuously check something?

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [July 16, 2008, 4:44am UTC](https://forum.kirupa.com/t/if-questions/266071/5 "2008-07-16T04:44:35Z")

</div>

Void in that case is the return type of the function. Since the function doesn’t return anything, the return type is Void (which means nothing). If you were returning an Array, for example, you would write it like this:

```auto
function test():Array {
     return new Array();
}

```

trace just displays the passed data (converted to a string) in the output window.

---

<div class="post-metadata">

**Author:** ![spyderfx](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@spyderfx](https://forum.kirupa.com/u/spyderfx)\
**Post date:** [July 16, 2008, 5:05am UTC](https://forum.kirupa.com/t/if-questions/266071/6 "2008-07-16T05:05:26Z")

</div>

brilliant! so that’s how you do array’s. i only learned those in VB 6.0 and they were incredibly useful.

awesome:mario:

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [July 16, 2008, 5:07am UTC](https://forum.kirupa.com/t/if-questions/266071/7 "2008-07-16T05:07:48Z")

</div>

[QUOTE=spyderfx;2359490]brilliant! so that’s how you do array’s. i only learned those in VB 6.0 and they were incredibly useful.

awesome:mario:[/QUOTE]

That’s how you return an array from a function. To just create an array you would do:

```auto
var a:Array = new Array();
//or
var b:Array = [];

```
