Parseint Function - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

parseInt function

parseInt(expression:String, [radix:Number]) : Number
Converts a string to an integer. If the specified string in the parameters cannot be converted to
a number, the function returns
numbers. Integers beginning with 0 or specifying a radix of 8 are interpreted as octal numbers.
White space preceding valid integers is ignored, as are trailing nonnumeric characters.
Availability: ActionScript 1.0; Flash Player 5
Parameters
expression:String
[optional] - An integer representing the radix (base) of the number to parse.
radix:Number
Legal values are from 2 to 36.
Returns
- A number or
Number
Example
The examples in this section use the
numbers.
The following example returns 3:
parseInt("3.5")
The following example returns
parseInt("bar")
The following example returns 4:
parseInt("4foo")
The following example shows a hexadecimal conversion that returns 1016:
parseInt("0x3F8")
The following example shows a hexadecimal conversion using the optional
that returns 1000:
parseInt("3E8", 16)
The following example shows a binary conversion and returns 10, which is the decimal
representation of the binary 1010:
parseInt("1010", 2)
The following examples show octal number parsing and return 511, which is the decimal
representation of the octal 777:
parseInt("0777")
parseInt("777", 8)
. Strings beginning with 0x are interpreted as hexadecimal
NaN
- A string to convert to an integer.
(not a number).
NaN
parseInt()
:
NaN
function to evaluate various types of
parameter
radix
Global Functions
87

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents

Save PDF