Jeff Lee
Jeff Lee

Reputation: 1336

ActionScript 3 package structure and directory structure

I seem to run into compile issues in Flash Builder when I import 3rd-party libraries at the wrong level in the directory structure.

For example, sometimes I'll import a library one level too deep into its directory tree, and the package explorer ends up excluding the prefix root-level package, usually "com." or "net.". Even though the content of the source itself doesn't change, this will cause compile errors.

Thus:

Upvotes: 0

Views: 1103

Answers (1)

weltraumpirat
weltraumpirat

Reputation: 22604

It is a language requirement, and it's one that ActionScript shares with Java. The Wikipedia article on Java packages offers a fitting description:

The Java Language Specification establishes package naming conventions to avoid the possibility of two published packages having the same name. The naming conventions describe how to create unique package names, so that packages that are widely distributed will have unique namespaces. This allows packages to be separately, easily and automatically installed and catalogued.

I would add that by keeping the class files in a corresponding folder structure, it is possible to combine complete or partial projects (such as frameworks and/or components) by importing an existing folder structure - without the risk of naming conflicts and/or overwriting existing files. It also helps finding a particular class when you are working with large code bases.

Upvotes: 1

Related Questions