The
statement lets you access classes without specifying their fully qualified names.
import
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
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
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
statement applies only to the current script (frame or object) in which it's called.
import
For example, suppose on Frame 1 of a Flash document you import all the classes in the
package. On that frame, you can reference classes in the package by using their
macr.util
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.
500
Animation, Filters, and Drawings
statement, lets you access the BlurFilter using the
import
statement, as seen in the
import
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?