500
Animation, Filters, and Drawings
The
import
statement lets you access classes without specifying their fully qualified names.
For example, to use a BlurFilter in a script, you must refer to it by its fully qualified name
(flash.filters.BlurFilter) or import it; if you import it, you can refer to it by its class name
(BlurFilter) in your code instead. The following ActionScript code demonstrates the
differences between using the import statement and using fully qualified class names.
If you don’t import the BlurFilter class, your code needs to use the fully qualified class name
(package name followed by class name) in order to use the filter:
// without importing
var myBlur:flash.filters.BlurFilter = new flash.filters.BlurFilter(10, 10,
3);
The same code, written with an
import
statement, lets you access the BlurFilter using the
class name instead of continually referencing it using the fully qualified name. This can save
typing and reduces the chance of making typing mistakes:
// with importing
import flash.filters.BlurFilter;
var myBlur:BlurFilter = new BlurFilter(10, 10, 3);
To import several classes within a package (such as the BlurFilter, DropShadowFilter, and
GlowFilter) you can use one of two ways to import each class. The first way to import
multiple classes is to import each class by using a separate
import
statement, as seen in the
following snippet:
import flash.filters.BlurFilter;
import flash.filters.DropShadowFilter;
import flash.filters.GlowFilter;
If you use individual import statements for each class within a package, it becomes time
consuming to write and prone to typing mistakes. You can avoid importing individual class
files by using a
wildcard
import, which imports all classes within a certain level of a package.
The following ActionScript shows an example of using a wildcard import:
import flash.filters.*; // imports each class within flash.filters package
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 the package by using their
class names instead of their fully qualified name. To use the class name on another frame
script, 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.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...