
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Primitive Data Versus Composite Data
|
73
Here are a few examples:
trace(typeof "game over"); // Displays: "string" in the Output window
var x = 5;
trace(typeof x); // Displays: "number"
var now = new Date();
trace(typeof now); // Displays: "object"
As shown in Example 3-1, when combined with a for-in statement, typeof provides a
handy way to find all the movie clip instances on a timeline. Once the clips are iden-
tified, we can assign them to an array for programmatic handling. (If you can’t fol-
low all of Example 3-1, revisit it after completing Part I.)
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 represents a single datum (as opposed to an array of multiple
items) and holds that datum directly, rather than holding its address elsewhere in
memory.
ActionScript supports these primitive datatypes: number, string, boolean, undefined,
and null. ActionScript does not have a separate single-character datatype (e.g., char)
as found in C/C++ (strings are a primitive datatype in ActionScript, and not arrays of
chars as they are in C/C++).
Function “function“
undefined “undefined“
Example 3-1. Populating an array with dynamically ...