# Modifying the classpath

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:

1. Open the Preferences dialog box by selecting Edit > Preferences.
2. Click the ActionScript tab, then click the ActionScript 2.0 Settings button.
3. To add a path to the classpath, do one of the following:

- Click the Browse to Path button to open the Browse dialog, browse to the folder you'd like to add to the classpath, and click OK.
- Click the Add new Path button (+) to add a new line to the Classpath list. Double-click the new line, type a relative or absolute path, then click OK.

1. To edit an existing path, do one of the following:

- Select the path to be edited in the Classpath list, click the Browse to Path button to open the Browse dialog, browse to the folder you'd like to add to the classpath, and click OK.
- Double-click the path in the Classpath list, type the desired path, then click OK.

1. To delete a path, select it in the Classpath list and click the Remove from Path button.

To modify the document-level classpath:

1. Open the Publish Settings dialog box by selecting File > Publish Settings.
2. Click the Flash tab.
3. Click the Settings button next to the ActionScript Version pop-up menu.
4. To add a folder to the classpath, do one of the following:

- Click the Browse to Path button to open the Browse dialog, browse to the folder you'd like to add to the classpath, and click OK.
- Click the Add new Path button (+) to add a new line to the Classpath list. Double-click the new line, type a relative or absolute path, then click OK.

1. To edit an existing classpath folder, do one of the following:

- Select the path to be edited in the Classpath list, click the Browse to Path button to open the Browse dialog, browse to the folder you'd like to add to the classpath, and click OK.
- Double-click the path in the Classpath list, type the desired path, then click OK.

1. To delete a folder from the classpath, select the path in the Classpath list and click the Remove from Path button.

### About relative classpath settings

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 folder—it 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>>.