SWiSH Player Support
SWF5 or later - Supported Internally
Syntax
parseFloat(string)
Arguments
string: The string to read and convert to a floating-point number.
Returns
Nothing.
Description
Function: Converts a string to a floating-point number. The function reads, or 'parses', and returns the numbers in a string until it reaches a character that is not a part of the initial number. If the string does not begin with a number that can be parsed, parseFloat returns NaN (not a number). White space preceding valid integers is ignored, as are trailing non-numeric characters.
Sample
The following examples use the parseFloat function to evaluate various types of numbers:
trace(parsefloat("-4.9")); // displays -4.9
trace(parsefloat("-4e3")); // displays -4000
trace(parsefloat("-4.9stuff")); // displays 0
trace(parsefloat("garbage")); // displays 0
Flash MX Differences
Flash supports the concept of NaN, SWiSH returns 0 in these instances.
See Also
parseInt() and Number().