You can modify the global classpath using the Preferences dialog. To modify the document-level classpath setting you use the Publish Settings dialog for the FLA file. You can add both absolute ("C:/my_classes", for example) and relative folder paths ("..\my_classes" or ".", for example).
By default, the global classpath contains one absolute path ($UserConfig/Classes) and a relative classpath, denoted by a single dot (.), that points to the current document folder. Beware that relative classpaths can point to different folders, depending on the location of the document being compiled or published. For more information see About relative classpath settings.
To modify the global classpath:
To modify the document-level classpath:
It's important to remember that relative classpaths may point to different folders, depending on the location of the document (AS or FLA file) being compiled or published. For example, imagine that you have an application that consists of one FLA document, and two ActionScript class files, in the following folder hierarchy.
main.fla classes/foo.as classes/bar.as
By default, the global classpath setting includes the current working directory, or ".". But unless your FLA files and AS files are located in the same folder, the current working directory can mean different things.
For example, suppose you're working on a project that consists of a FLA file and two AS files, in the following directory structure:
c:\Project\Main.fla
c:\Project\pkg1\myClass_1.as
c:\Project\pkg2\myClass_2.as
In the Main.fla file, a frame script references package pkg1.myClass_1
in an import
statement:
import pkg1.myClass_1;
In this case, the relative classpath setting "." points to c:\Project, the folder that contains the FLA file. The reference to pkg1.myClass_1
resolves successfully, since c:\Project contains the package named pkg1.
Now, suppose that within myClass_1.as, a reference is made to pkg2.myClass_2, as shown here:
// Inside pkg1/myClass_1.as: import pkg2.myClass_2; class pkg1.myClass_1 { }
In this case, the "." relative classpath setting points to C:\Project\pkg1, which contains myClass_1.as. But pkg2 does not reside in that folderit is up one level in the folder hierarchy. As a result, the reference to pkg2.myClass_2 will fail with the error "The class pkg2.myClass_2 could not be loaded."
To solve this problem, you would modify the global classpath to include the folder that contains both pkg1 and pkg2. You could add either the absolute path to that folder (C:\Project), or the relative path (..). Using relative paths will let you move the entire project folder to another location without modifying the classpath again.
Another solution is to keep ActionScript class files for all your projects in a single folder, and then simply add the location of that folder to the global classpath setting.
Yet another solution is to keep all your FLA and AS files in a single folder, although this approach can be difficult if your project contains many FLA and AS files.
For information on modifying classpaths see Modifying the classpath or <<xref to Using Flash: Setting classpaths>>.