
34
Chapter 2: ActionScript Basics
About data types
A data type describes the kind of information a variable or ActionScript element can hold. There
are two kinds of data types built into Flash: primitive and reference. The primitive data types—
String, Number, and Boolean—have a constant value and therefore can hold the actual value of
the element they represent. The reference data types—MovieClip and Object—have values that
can change and therefore contain references to the actual value of the element. Variables
containing primitive data types behave differently in certain situations than those containing
reference types. (See
“Using variables in a program” on page 43
.) There are also two special data
types: null and undefined.
In Flash, any built-in object that isn’t a primitive data type or a movie clip data type, such as Array
or Math, is of the Object data type.
Each data type has its own rules and is described in the following topics:
•
“String” on page 34
•
“Number” on page 35
•
“Boolean” on page 35
•
“Object” on page 36
•
“MovieClip” on page 36
•
“Null” on page 36
•
“Undefined” on page 36
When you debug scripts, you may 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
typeof
operator (see
“Determining an item’s data type” on page 37
).
You can convert one data type to another using one of the following conversion functions:
Array()
,
Boolean()
,
Number()
,
Object()
,
String()
.
String
A string is a sequence of characters such as letters, numbers, and punctuation marks. You enter
strings in an ActionScript statement by enclosing them in single or double quotation marks.
Strings are treated as characters instead of as variables. For example, in the following statement,
"L7"
is a string:
favoriteBand = "L7";
You can use the addition (+) operator to
concatenate
, or join, two strings. ActionScript treats
spaces at the beginning or end of a string as a literal part of the string. The following expression
includes a space after the comma:
greeting = "Welcome," + firstName;
Содержание FLASH MX 2004 - ACTIONSCRIPT
Страница 1: ...ActionScript Reference Guide...
Страница 8: ...8 Contents...
Страница 12: ......
Страница 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Страница 54: ...54 Chapter 2 ActionScript Basics...
Страница 80: ...80 Chapter 3 Writing and Debugging Scripts...
Страница 82: ......
Страница 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Страница 112: ......
Страница 120: ...120 Chapter 6 Using the Built In Classes...
Страница 176: ......
Страница 192: ...192 Chapter 10 Working with External Data...
Страница 202: ...202 Chapter 11 Working with External Media...
Страница 204: ......
Страница 782: ...782 Chapter 12 ActionScript Dictionary...
Страница 793: ...Other keys 793 221 222 Key Key code...
Страница 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Страница 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Страница 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Страница 816: ...816 Index...