
Data type descriptions
The primitive data types include Boolean, int, Null, Number,
String, uint, and void. The ActionScript core classes also define
the following complex data types: Object, Array, Date, Error, Function,
RegExp, XML, and XMLList.
Boolean data typeThe Boolean data type comprises two values:
true
and
false
. No other values are valid for variables of Boolean type.
The default value of a Boolean variable that has been declared but
not initialized is
false
.
int data typeThe int data type is stored internally as a 32bit integer
and comprises the set of integers from
2,147,483,648 (2^{31}) to 2,147,483,647 (2^{31} 
1), inclusive. Previous versions of ActionScript offered only the
Number data type, which was used for both integers and floatingpoint
numbers. In ActionScript 3.0, you now have access to lowlevel machine
types for 32bit signed and unsigned integers. If your variable will
not use floatingpoint numbers, using the int data type instead
of the Number data type should be faster and more efficient.
For integer values outside the range of
the minimum and maximum int values, use the Number data type, which
can handle values between positive and negative 9,007,199,254,740,992
(53bit integer values). The default value for variables that are
of the data type int is 0.
Null data typeThe Null data type contains only one value,
null
. This is the default value for the String data type and
all classes that define complex data types, including the Object
class. None of the other primitive data types, such as Boolean,
Number, int and uint, contain the value
null
. Flash Player and Adobe AIR will convert the value
null
to the appropriate default value if you attempt to assign
null
to variables of type Boolean, Number, int, or uint. You
cannot use this data type as a type annotation.
Number data typeIn ActionScript 3.0, the Number data type
can represent integers, unsigned integers, and floatingpoint numbers.
However, to maximize performance, you should use the Number data
type only for integer values larger than the 32bit
int
and
uint
types can store or for floatingpoint numbers. To store
a floatingpoint number, include a decimal point in the number.
If you omit a decimal point, the number will be stored as an integer.
The
Number data type uses the 64bit doubleprecision format as specified
by the IEEE Standard for Binary FloatingPoint Arithmetic (IEEE754).
This standard dictates how floatingpoint numbers are stored using
the 64 available bits. One bit is used to designate whether the
number is positive or negative. Eleven bits are used for the exponent,
which is stored as base 2. The remaining 52 bits are used to store
the
significand
(also called the
mantissa
), which is the number that is raised to the power indicated
by the exponent.
By using some of its bits to store an exponent, the Number data
type can store floatingpoint numbers significantly larger than
if it used all of its bits for the significand. For example, if
the Number data type used all 64 bits to store the significand,
it could store a number as large as 2^{65}  1. By using
11 bits to store an exponent, the Number data type can raise its
significand to a power of 2^{1023}.
The maximum and minimum values that
the Number type can represent are stored in static properties of
the Number class called
Number.MAX_VALUE
and
Number.MIN_VALUE
.
Number.MAX_VALUE == 1.79769313486231e+308
Number.MIN_VALUE == 4.940656458412467e324
Although
this range of numbers is enormous, the cost of this range is precision. The
Number data type uses 52 bits to store the significand, with the
result that numbers that require more than 52 bits to represent
precisely, such as the fraction 1/3, are only approximations. If
your application requires absolute precision with decimal numbers,
you need to use software that implements decimal floatingpoint
arithmetic as opposed to binary floatingpoint arithmetic.
When
you store integer values with the Number data type, only the 52
bits of the significand are used. The Number data type uses these
52 bits and a special hidden bit to represent integers from 9,007,199,254,740,992
(2^{53}) to 9,007,199,254,740,992 (2^{53}).
Flash Player and Adobe AIR use the
NaN
value not only as the default value for variables of type
Number
, but also as the result of any operation that should return
a number but does not. For example, if you attempt to calculate
the square root of a negative number, the result will be
NaN
. Other special Number values include
positive infinity
and
negative infinity
.
Note: The
result of division by
0
is only
NaN
if the divisor is also
0
. Division by
0
produces
infinity
when the dividend is positive or
infinity
when the dividend is negative.
String data typeThe String data type represents a sequence
of 16bit characters. Strings are stored internally as Unicode characters,
using the UTF16 format. Strings are immutable values, just as they
are in the Java programming language. An operation on a String value
returns a new instance of the string. The default value for a variable
declared with the String data type is
null
. The value
null
is not the same as the empty string (
""
), even though they both represent the absence of any characters.
uint data typeThe uint
data type is stored internally as a 32bit unsigned integer and
comprises the set of integers from 0 to 4,294,967,295 (2^{32} 
1), inclusive. Use the uint data type for special circumstances
that call for nonnegative integers. For example, you must use the
uint data type to represent pixel color values, because the int data
type has an internal sign bit that is not appropriate for handling
color values. For integer values larger than the maximum uint value,
use the Number data type, which can handle 53bit integer values.
The default value for variables that are of data type uint is 0.
void data typeThe void data type contains only one value,
undefined
. In previous versions of ActionScript,
undefined
was the default value for instances of the Object class. In
ActionScript 3.0, the default value for Object instances is
null
. If you attempt to assign the value
undefined
to an instance of the Object class, Flash Player or Adobe
AIR will convert the value to
null
. You can only assign a value of
undefined
to variables that are untyped. Untyped variables are variables
that either lack any type annotation, or use the asterisk (
*
) symbol for type annotation. You can use
void
only as a return type annotation.
Object data typeThe
Object data type is defined by the Object class. The Object class
serves as the base class for all class definitions in ActionScript.
The ActionScript 3.0 version of the Object data type differs from
that of previous versions in three ways. First, the Object data
type is no longer the default data type assigned to variables with
no type annotation. Second, the Object data type no longer includes
the value
undefined
, which used to be the default value of Object instances.
Third, in ActionScript 3.0, the default value for instances of the
Object class is
null
.
In previous versions
of ActionScript, a variable with no type annotation was automatically
assigned the Object data type. This is no longer true in ActionScript
3.0, which now includes the idea of a truly untyped variable. Variables
with no type annotation are now considered untyped. If you prefer
to make it clear to readers of your code that your intention is
to leave a variable untyped, you can use the new asterisk (
*
) symbol for the type annotation, which is equivalent to omitting
a type annotation. The following example shows two equivalent statements,
both of which declare an untyped variable
x
:
var x
var x:*
Only untyped variables
can hold the value
undefined
. If you attempt to assign the value
undefined
to a variable that has a data type, Flash Player or Adobe AIR
will convert the value
undefined
to the default value of that data type. For instances
of the Object data type, the default value is
null
, which means that Flash Player or Adobe AIR will convert
the value
undefined
to
null
if you attempt to assign
undefined
to an Object instance.
