
52
Chapter 3: Using ActionScript
You can also use the wildcard character (*) to import all the classes in a given package. For
example, the following statement imports all classes in the MyPackage.Util package:
import MyPackage.Util.*;
Flex searches the ActionScript classpath for imported files and packages.
If you import a class but do not use it in your application, the class is not included in the resulting
SWF file’s bytecode. As a result, importing an entire package with a wildcard does not create an
unnecessarily large SWF file.
About the ActionScript classpath
ActionScript classes that you use in your applications must be in a directory that is in the
ActionScript classpath. By default, the
flex_app_root
/WEB-INF/flex/user_classes directory is part
of the ActionScript classpath. In addition, ActionScript classes can be in the same directory or
subdirectories as the MXML file. ActionScript classes can also be in component SWC files.
The order of the classpath entries is important. When Flex encounters classes that share the same
name, it uses the class that it found first in the classpath. The rest are ignored.
Flex loads ActionScript classes in the following order:
1.
Local *.as files in the same directory or subdirectories as the currently executing application.
2.
Classes in
flex_app_root
/WEB-INF/flex/user_classes.
3.
Classes specified the
<actionscript-classpath>
tag in the flex-config.xml file.
4.
Classes defined in components (SWC files) used by the currently executing application.
This includes the SWC files in the frameworks and frameworks_debug directories, as well as
custom components. Directories containing accessible SWC files are defined by the
<compiler>
tag’s
<lib-path>
entries in the flex-config.xml file. For more information, see
Developing Flex Applications
.
You can add additional directories to the Flex ActionScript classpath with the
<path-element>
child tag of the
<actionscript-classpath>
tag in the flex-config.xml file. Flex searches for
classes in the order in which they appear in this list.
The following example shows the default user_classes directory and two additional directories
added to the ActionScript classpath:
<compiler>
<actionscript-classpath>
<path-element>/WEB-INF/flex/user_classes</path-element>
<path-element>/WEB-INF/flex/3rd_party_packages</path-element>
<path-element>/WEB-INF/flex/test_dir</path-element>
</actionscript-classpath>
</compiler>
For more information on the
<compiler>
settings, see Chapter 39, “Administering Flex,” in
Developing Flex Applications
.
Содержание FLEX-GETTING STARTED WITH FLEX
Страница 1: ...Getting Started with Flex...
Страница 4: ...4 Contents...
Страница 22: ...22 Chapter 1 Introducing Flex...