Andy,
Like the other poster said, us isNaN, but I was also curious about why
this might be true.
I found this link on the subject that will be helpful (original page
down):
http://209.85.165.104/search?q=cache:ilnSqw-hBjwJ:livedocs.macromedia.com/flex/2/langref/package.html+Flash+NaN+equality&hl=en&gl=us&ct=clnk&cd=3
"The |*NaN*| value is not considered equal to any other value, including
|*NaN*|, which makes it impossible to use the *equality* operator to
test whether an expression is |*NaN*|. To determine whether a number is
the |*NaN*| function, use |isNaN()|."
Brandon
-----------------
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