Simply use isNAN() method :
http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhel
p.htm?context=LiveDocs_Parts&file=00001737.html

if (isNAN(fooN)¨{
        // do stuff
else {
        // do else stuff
} 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Andy Herrman
Sent: 1 février 2007 12:12
To: Flashcoders
Subject: [Flashcoders] Detecting NaN

I'm trying to convert an arbitrary object into a Number, and then detect if
the conversion actually succeeded.  In theory I would convert it and then
check if the converted value is NaN, but this doesn't seem to work.

Here's my test.  In a blank FLA I put the following code:

----------
var foo = "foobar";
var fooN:Number = Number(foo);
trace(typeof(fooN));
if(fooN == NaN) {
        trace("fooN is NaN");
} else {
        trace("fooN is a number: " + fooN);
}
----------

This should output:
number
fooN is NaN

but instead I get:
number
fooN is a number: NaN

For some reason the check to see if it's NaN isn't working, and I have no
idea why.

It looks like I can use isNaN(fooN) for the check instead, but I'm wondering
why == doesn't work.

   -Andy
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training http://www.figleaf.com
http://training.figleaf.com


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.411 / Virus Database: 268.17.18/662 - Release Date: 2007-01-31
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.411 / Virus Database: 268.17.18/662 - Release Date: 2007-01-31
 

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to