AS# and FLEX quick FYI: Number & int
by Carlos Pinho, June 25th, 2007
  • Share
  • Share

flex3_fx_124x120.jpgjwopitz wrote:

Now I am not what you call an ActionScript know-it-all. In fact, I learn something nearly everyday about AS3 and Flex. That’s why I love my job. So I ran into an issue where I was using isNaN expecting to get true. Various values were getting passed in but I wasn’t getting consistent results. Why?

Well part of that was that I was passing int(s) as values. I hadn’t initialized the var to anything. I just said var i:int; much like we might define var n:Number; and its initialized value would be the numerical equivalent to null which is NaN.

Little to my knowledge this was occuring:

var n:Number;
trace(isNaN(n)); //true, because the default value of a Number is NaN
var i:int;
trace(isNaN(i)); //false, because int defaults to 0, not NaN

Cool tip? I’d like to think so. Anywho…

Brgds,
CP

Copy and Paste the code below
Email and IM
Websites
Forums
Get This

No Responses to “AS# and FLEX quick FYI: Number & int”

  1. Theo Says:

    Well, it’s in the specs…

Let leave a Comments for this post.