
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
64
|
Chapter 3: Data and Datatypes
Programming languages use datatypes to provide rudimentary categories for data.
For example, nearly all programming languages define datatypes to store and manip-
ulate text (a.k.a. strings) and numbers. To distinguish between multiple numbers, we
can use well-conceived variable names, such as
phoneNumber and faxNumber. In more
complex situations, we can create our own custom data categories with objects and
object classes, as covered in Chapter 12. Before we think about making our own data
categories, let’s see which categories come built into ActionScript.
The ActionScript Datatypes
When programming, we may want to store a product name, a background color, or
the number of stars to be placed in a night sky. We use the following ActionScript
datatypes to store our data:
string
For text sequences such as “
hi there”. A string is a series of characters (alphanu-
merics and punctuation).
number
For numbers, such as 351 and 7.5. Numbers are used for counting and for math-
ematical equations.
boolean
For logical decisions. With Boolean data, we can represent or record the status
of some condition or the result of some comparison. Boolean data has only two
legal values:
true and false.
null and undefined
For representing an absence of data, ActionScript provides two ...