32
Flash Lite Global Functions
Number()
Availability
Flash Lite 1.0.
Usage
Number(
expression
)
Operands
expression
An expression to convert to a number.
Description
Function; converts the parameter
expression
to a number and returns a value as described in
the following list:
■
If
expression
is a number, the return value is
expression
.
■
If
expression
is a Boolean value, the return value is 1 if
expression
is
true
; 0 if
expression
is
false
.
■
If
expression
is a string, the function attempts to parse
expression
as a decimal
number with an optional trailing exponent (that is, 1.57505e-3).
■
If
expression
is
undefined
, the return value is -1.
Example
The following example converts the string in the
myString
variable to a number, stores the
number in the
myNumber
variable, adds 5 to the number, and stores the result in the variable
myResult
. The final line shows the result when you call
Number()
on a Boolean value.
myString = "55";
myNumber = Number(myString);
myResult = my 5;
trace (myResult); // Output: 60
trace (Number(true));// Output: 1
Summary of Contents for FLASH 8-FLASH
Page 1: ...Flash Lite 1 x ActionScript Language Reference...
Page 6: ...6 Contents...
Page 46: ...46 Flash Lite Global Functions...
Page 62: ...62 Flash Lite Properties...
Page 76: ...76 Flash Lite Statements...
Page 110: ...110 Flash Lite Operators...
Page 162: ...162 Index...