takayoshi
takayoshi

Reputation: 2787

flash import class from another directory

Originally my classes(.as) and project (.fla) were stored in the same directory. But I would like to refactor them. I've created a subdirectory "classes", and moved my classes into this subdirectory but I've got error.

All my classes are stored in one package.

How can I "include" or "import" my classes from a subdirectory of my project?

Upvotes: 3

Views: 7754

Answers (2)

DingoEatingFuzz
DingoEatingFuzz

Reputation: 623

The problem is probably the .as files in the new folders. AS3 namespaces map to your filesystem. This means a class named Bar in the folder foo needs to be in the foo namespace.

Bar.as

package {

foo/Bar.as

package foo {

widget.as

package {
    import foo.Bar;

Which will look like this on your filesystem:

| Bar.as
- foo
   | Bar.as
| widget.as

Upvotes: 6

Kodiak
Kodiak

Reputation: 5978

Two solutions:

  1. Add your subdirectory to your library path (click on Edit next to ActionScript settings in the property panel and then on the first tab just add your directory)
  2. In your class file just change the package to nameofthesubdirectory

Upvotes: 1

Related Questions