Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 68

Programming actionscript 3.0
Table of Contents

Advertisement

In ActionScript 3.0, the
you supply a string with a leading zero to the ActionScript 2.0
number is interpreted as an octal number, and converted to its decimal equivalent. This is not
true with the
Number()
For example, the following code generates different output when compiled using different
versions of ActionScript:
trace(Number("044"));
// ActionScript 3.0 44
// ActionScript 2.0 36
Casting is not necessary when a value of one numeric type is assigned to a variable of a
different numeric type. Even in strict mode, the numeric types are implicitly converted to the
other numeric types. This means that in some cases, unexpected values may result when the
range of a type is exceeded. The following examples all compile in strict mode, though some
will generate unexpected values:
var sampleUINT:uint = -3; // Assign value of type int and Number.
trace(sampleUINT); // 4294967293
var sampleNum:Number = sampleUINT; // Assign value of type int and uint.
trace(sampleNum) // 4294967293
var sampleINT:int = uint.MAX_VALUE + 1; // Assign value of type Number.
trace(sampleINT); // 0
sampleINT = int.MAX_VALUE + 1; // Assign value of type uint and Number.
trace(sampleINT); // -2147483648
The following table summarizes the results of casting to the Number, int, or uint data type
from other data types.
Data type or value
Boolean
Date
null
Object
String
undefined
68
ActionScript Language and Syntax
function no longer supports octal, or base 8, numbers. If
Number()
function in ActionScript 3.0, which instead ignores the leading zero.
Result of conversion to Number, int or uint
If the value is true, 1; otherwise, 0.
The internal representation of the Date object, which is the number
of milliseconds since midnight January 1, 1970, universal time.
0
If the instance is
null
A number if Flash Player can convert the string to a number;
otherwise,
if converted to Number or 0 if converted to int or uint.
NaN
If converted to Number,
Number()
and converted to Number,
; if converted to int or uint, 0.
NaN
function, the
; otherwise, 0.
NaN

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents