Primitive Data Versus Composite Data

So far we’ve been working mostly with numbers and strings, which are the most common primitive datatypes. Primitive datatypes are the basic units of a language; each primitive value contains a single datum (as opposed to an array of multiple items) and describes that datum literally. Primitive data is very straightforward.

ActionScript supports these primitive datatypes: number, string, boolean, undefined, and null. ActionScript does not have a separate single-character datatype (i.e., char) as found in C/C++.

Primitive datatypes are, as their name suggests, simple. They can hold text messages, frame numbers, movie clip size values, and so on, but they don’t readily accommodate higher levels of complexity. For more elaborate data handling—such as simulating the physics of a dozen bouncing balls or managing a quiz with 500 questions and answers—we turn to composite datatypes. Using composite data, we can manage multiple pieces of related data as a single datum.

ActionScript supports the following composite datatypes: array, object, and movieclip. Functions are technically a type of object and are therefore considered composite data, but we rarely manipulate them as such. See Chapter 9, for more about functions as a datatype.

Whereas a single number is a primitive datum, a list (i.e., an array) of multiple numbers is a composite datum. Here’s a practical example of how composite datatypes are useful: Suppose we wanted to track the profile of a customer ...

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.