Flash CS4 Professional ActionScript 2.0

About primitive and complex data types

You can divide all the different data type values into two main categories: primitive or complex.

A primitive value (or primitive data type) is a value that ActionScript stores at the lowest level of abstraction, which means that operations on the primitive data types are generally faster and more efficient than operations carried out on complex data types. The following data types all define a set of one or more primitive values: Boolean, null, Number, String, and undefined.

A complex value (or complex data type) is a value that is not a primitive value and that references the primitive values. Often, these are called reference data types. Complex values belong to the Object data type or a data type that is based on the Object data type. Data types that define sets of complex values include Array, Date, Error, Function, and XML. For more information on these complex data types, see their entries in the ActionScript 2.0 Language Reference.

Variables that contain primitive data types behave differently in certain situations than those containing complex types. For more information, see Using variables in a project.

ActionScript has the following basic data types that you can use in your applications:

Data type

Description

Boolean

Primitive. The Boolean data type consists of two values: true and false. No other values are valid for variables of this type. The default value of Boolean variable that has been declared but not initialized is false. For more information, see Boolean data type.

MovieClip

Complex. The MovieClip data type lets you control movie clip symbols using the methods of the MovieClip class. For more information, see MovieClip data type.

null

Primitive. The null data type contains the value null. This value means no value--that is, a lack of data. You can assign the null value in a variety of situations to indicate that a property or variable does not have a value assigned to it. The null data type is the default data type for all classes that define complex data types. An exception to this rule is the Object class, which defaults to undefined. For more information, see null data type.

Number

Primitive. This data type can represent integers, unsigned integers, and floating point numbers. To store a floating point number, you should include a decimal point in the number. Without the decimal point, the number is stored as an integer. The Number data type can store values from Number.MAX_VALUE (very high) to Number.MIN_VALUE (very low). For more information, see ActionScript 2.0 Language Reference and Number data type.

Object

Complex. The Object data type is defined by the Object class. The Object class serves as the base class for all class definitions in ActionScript, and it lets you arrange objects inside each other (nested objects). For more information, see Object data type.

String

Primitive. The String data type represents a sequence of 16-bit characters that might include letters, numbers, and punctuation marks. Strings are stored as Unicode characters, using the UTF-16 format. An operation on a String value returns a new instance of the string. For more information, see String data type.

undefined

Primitive. The undefined data type contains one value: undefined. This is the default value for instances of the Object class. You can only assign a value of undefined to variables that belong to the Object class. For more information, see undefined data type.

Void

Complex. The Void data type contains only one value: void. You use this data type to designate functions that don't return a value. Void is a complex data type that references the primitive Void data type. For more information, see Void data type.

For a sample of the datatypes.fla file, see the Flash Samples page at www.adobe.com/go/learn_fl_samples. Download and decompress the Samples zip file and navigate to the ActionScript2.0/DataTypes folder to access the sample.