Search code examples
flashactionscript-3fla

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?


Solution

  • 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