开发者

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 开发者_如何学JAVAcreated 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?


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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜