If questions

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

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

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

Try something like this;


var lives:Number = 15;

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

killOneLife();

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?

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:

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

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

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=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:

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