About object-oriented programming and Flash
231
The
import
statement applies only to the current script (frame or object) in which it’s called.
For example, suppose on Frame 1 of a Flash document you import all the classes in the
macr.util package. On that frame, you can reference classes in that package by their class
names instead of their fully qualified names. If you wanted to use the class name on another
frame script, however, you would need to reference classes in that package by their fully
qualified names or add an
import
statement to the other frame that imports the classes in
that package.
When using
import
statements, it’s also important to note that classes are imported only for
the level specified. For example, if you imported all classes in the mx.transitions package, only
those classes within the /transitions/ directory are imported, not all classes within
subdirectories (such as the classes in the mx.transitions.easing package).
About values and data types
Data, values, and types are important when you start writing classes and using them. You
learned about data and types in
Chapter 4, “Data and Data Types,” on page 71
. When you
work with classes, remember that data types describe the kind of information a variable or
ActionScript element can contain, such as Boolean, Number, and String. For more
information, see
“About data types” on page 72
.
Expressions have values, while values and properties have
types
. The values that you can set
and get to and from a property in your class must be compatible with that property. Type
compatibility means the type of a value is compatible with the type that is in use, such as the
following example:
var myNum:Number = 10;
For more information on strict data typing, see
“About assigning data types and strict data
typing” on page 81
.
Object-oriented programming fundamentals
In the following sections, you will examine some of the terminology used throughout this
chapter before you start writing ActionScript code. This brief introduction to principles
involved in developing object-oriented programs helps you follow the examples and sections
within this chapter and the rest of this book. These principles are described in more depth in
the rest of this chapter, along with details on how they are implemented in Flash 8.
TIP
If you import a class but don't use it in your script, the class isn't exported as part of the
SWF file. This means you can import large packages without being concerned about the
size of the SWF file; the bytecode associated with a class is included in a SWF file only if
that class is actually used.
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...