SWiSH Player Support
SWF4 or later - Supported Internally
Syntax
Number(expression)
Arguments
expression: The expression to convert to a floating-point number.
Returns
Converted number.
Description
Function: Converts an expression to a floating-point number.
If expression is a string, behaves like parseFloat().
If expression is boolean, returns 1 if true, 0 if false.
If expression is numeric, returns the result of the expression.
Sample
The following examples use the Number function to evaluate various expressions:
trace(Number("-4e3")); // displays -4000
trace(Number(4 + 3)); // displays 7
trace(Number(4 > 3)); // displays 1 (boolean true)
trace(Number("garbage")); // displays 0
Flash MX Differences
Flash supports the concept of NaN, SWiSH returns 0 in these instances.
See Also
parseFloat() and parseInt().