![MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference Download Page 18](http://html1.mh-extra.com/html/macromedia/flex-flex-actionscript-language/flex-flex-actionscript-language_reference_3387192018.webp)
18
Chapter 1: ActionScript Basics
Constants
A constant is a property whose value never changes. ActionScript contains predefined constants.
For example, the constants
BACKSPACE
,
ENTER
,
SPACE
, and
TAB
are properties of the Key object
and refer to keyboard keys. To test whether the user is pressing the Enter key, you could use the
following statement:
if(Key.getCode() == Key.ENTER) {
alert = "Are you ready to play?";
control_mc.gotoAndStop(5);
}
Flash does not enforce constants; that is, you can’t define your own constants.
About data types
A data type describes a piece of data and the kinds of operations that can be performed on it. That
data is stored in a variable. You use data types when creating variables, object instances, and
function definitions.
ActionScript has the following basic data types that you will probably use frequently in your
applications:
•
“String data type” on page 19
•
“Number data type” on page 19
•
“Boolean data type” on page 20
•
“Object data type” on page 21
•
“Null data type” on page 22
•
“Undefined data type” on page 23
•
“Void data type” on page 23
ActionScript also has built-in classes, such as Array and Date, that can be considered complex
data types. If you are an advanced developer, you might create custom classes. Any class that you
define using the
class
declaration is also considered a data type.
Variables containing primitive data types behave differently in certain situations than those
containing reference types. (See
“Using variables in a program” on page 29
.) There are also two
special data types: null and undefined.
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
operator
(see
“Determining an item’s data type” on page 26
).
You can convert one data type to another using one of the following conversion functions:
Array()
,
Boolean()
,
Number()
,
Object()
,
String()
.
In ActionScript 2.0, you can assign data types to variables when you initialize them. The data
types you assign can be any of the built-in types or can represent a custom class that you’ve
created. For more information, see
“Strict data typing” on page 24
.
For more information on Flex data types, see
Developing Flex Applications
.
Summary of Contents for FLEX-FLEX ACTIONSCRIPT LANGUAGE
Page 1: ...Flex ActionScript Language Reference...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Page 135: ...case 135 See also break default strict equality switch...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Page 808: ...808 Chapter 7 ActionScript for Flash...
Page 810: ...810 Appendix A Deprecated Flash 4 operators...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Page 822: ...822 Index...