72
Data and Data Types
Some of the most common kinds of data include strings (a sequence of characters, such as
names and passages of text), numbers, objects (such as movie clips), Boolean values (
true
and
false
), and so on. In this chapter, you’ll also learn about the data types in Flash and how to
use them.
For information on types of data, see
“About data types” on page 72
. For information on
variables, see
“About variables” on page 86
.
About data types
A
data type
describes a piece of data and the kinds of operations that you can perform on it.
You store data in a variable. You use data types when creating variables, object instances, and
function definitions to assign the type of data you’re working with. You use many different
data types when you write ActionScript.
ActionScript 2.0 defines several commonly used data types. Data types describe the kind of
value that a variable or ActionScript element can contain. A variable that is assigned a data
type can only hold a value within that data type’s set of values. For information on variables,
see
“About variables” on page 86
.
ActionScript has numerous basic data types that you will probably use frequently in your
applications. See the table in
“About primitive and complex data types” on page 73
for more
information.
ActionScript also has core classes, such as Array and Date, that are considered complex or
reference data types. For more info on complex and reference data types, see
“About primitive
and complex data types” on page 73
. In addition, all data types and classes are fully defined in
ActionScript 2.0 Language Reference
.
You can also create custom classes for your applications. Any class that you define using the
class declaration is also considered a data type. For more information on core and other built-
in classes, see
“About top-level and built-in classes” on page 286
. For more information on
creating custom classes, see
Chapter 7, “Classes,” on page 225
.
In ActionScript 2.0, you can assign data types to variables when you declare them. The data
types you assign can be any of the core types or can represent a custom class that you created.
For more information, see
“About assigning data types and strict data typing” on page 81
.
When you debug scripts, you might need to determine the data type of an expression or
variable to understand why it is behaving a certain way. You can do this with the
instanceof
and
typeof
operators (see
“About determining data type” on page 85
).
You can convert one data type to another at runtime using one of the following conversion
functions:
Array()
,
Boolean()
,
Number()
,
Object()
,
String()
.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...