
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
78
Chapter 4
CHAPTER 4
Primitive Datatypes
Primitive data consists of simple characters or keywords, such as the numbers 0, 1, 2,
3, 4, 5, 6, 7, 8, and 9, or the strings “a”, “b”, and “c”. As shown in Chapter 3, the
primitive datatypes supported by ActionScript are number, string, boolean, unde-
fined, and null. In this chapter, we’ll explore how to define, examine, and change
data of each type.
The Number Type
Numbers are used for counting, mathematics, and keeping track of numeric proper-
ties in our movies (such as the current frame of a movie clip or its location on the
Stage). Let’s see how numbers are defined and manipulated in ActionScript.
Integers and Floating-Point Numbers
Most programming languages distinguish between two kinds of numbers: integers
and floating-point numbers. An integer is a whole number that has no fractional com-
ponent. Integers can be positive, negative, or the number 0. Floating-point numbers
(floats for short) can include a fractional value represented after a decimal point, as
in 0.56, 199.99, and 3.14159. So, 1, 34523, –3, 0, and –9999999 are integers, but
223.45 and –0.56 are floats.
Numeric Literals
We learned earlier that a literal is a direct representation of a single, fixed data value.
The number type supports three kinds of literals: integer literals, ...