03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Converts a string to a floating-point number. The function reads, or parses, <strong>and</strong> returns the<br />

numbers in a string until it reaches a character that is not a part of the initial number. If the<br />

string does not begin with a number that can be parsed, parseFloat() returns NaN. White<br />

space preceding valid integers is ignored, as are trailing nonnumeric characters.<br />

Parameters<br />

string:String - The string to read <strong>and</strong> convert to a floating-point number.<br />

Returns<br />

Number - A number or NaN (not a number).<br />

Example<br />

The following examples use the parseFloat() function to evaluate various types of numbers:<br />

trace(parseFloat("-2")); // output: -2<br />

trace(parseFloat("2.5")); // output: 2.5<br />

trace(parseFloat(" 2.5")); // output: 2.5<br />

trace(parseFloat("3.5e6")); // output: 3500000<br />

trace(parseFloat("foobar")); // output: NaN<br />

trace(parseFloat("3.75math")); // output: 3.75<br />

trace(parseFloat("0garbage")); // output: 0<br />

See also<br />

NaN constant, parseInt function<br />

parseInt function<br />

parseInt(expression:String [, radix:Number]) : Number<br />

Converts a string to an integer. If the specified string in the parameters cannot be converted to<br />

a number, the function returns NaN. Strings beginning with 0x are interpreted as hexadecimal<br />

numbers. Integers beginning with 0 or specifying a radix of 8 are interpreted as octal numbers.<br />

White space preceding valid integers is ignored, as are trailing nonnumeric characters.<br />

Parameters<br />

expression:String - A string to convert to an integer.<br />

radix:Number [optional] - An integer representing the radix (base) of the number to parse.<br />

Legal values are from 2 to 36.<br />

Returns<br />

Number - A number or NaN (not a number).<br />

70 ActionScript language elements

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!