EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 231

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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, its 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.

Table of Contents

Related product manuals