Friday, June 4, 2010

Flex Goodness : NaN and Number

In flex, instead of using primitive datatypes like ent it is recommented Number datatype which supports double precision point floating number.

When a Number is not initialized, its value is NaN (Not a Number). Following are some methods which can be used to explore more about Number.

   1: var num:Number //this assigns a NaN value to it
   2: trace isNaN(num) //prints true
   3: trace int(num) //converts number to int and prints 0
   4: trace uint(num) //coverts number to uint   5:  
   6: var iStr:String = "1000"
   7: var convNum:Number = parseInt(iStr) //converts String to Number
   8: var convNumFloat:Number = parseFloat(iStr) //converts String to a float number

Enjoy Flexing!!

No comments:

Post a Comment