03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

isNaN function<br />

isNaN(expression:Object) : Boolean<br />

Evaluates the parameter <strong>and</strong> returns true if the value is NaN(not a number). This function is<br />

useful for checking whether a mathematical expression evaluates successfully to a number.<br />

Parameters<br />

expression:Object - A Boolean, variable, or other expression to be evaluated.<br />

Returns<br />

Boolean - A Boolean value.<br />

Example<br />

The following code illustrates return values for the isNaN() function:<br />

trace( isNaN("Tree") );<br />

// returns true<br />

trace( isNaN(56) );<br />

// returns false<br />

trace( isNaN(Number.POSITIVE_INFINITY) )<br />

// returns false<br />

The following example shows how you can use isNAN() to check whether a mathematical<br />

expression contains an error:<br />

var dividend:Number;<br />

var divisor:Number;<br />

divisor = 1;<br />

trace( isNaN(dividend/divisor) );<br />

// output: true<br />

// The output is true because the variable dividend is undefined.<br />

// Do not use isNAN() to check for division by 0 because it will return<br />

false.<br />

// A positive number divided by 0 equals Infinity<br />

(Number.POSITIVE_INFINITY).<br />

// A negative number divided by 0 equals -Infinity<br />

(Number.NEGATIVE_INFINITY).<br />

See also<br />

NaN constant, NaN (Number.NaN property)<br />

Global Functions 53

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!