如何从actionScript 3中的父目录导入类
我见过类似的问题,但不是这个具体问题
我有一个像这样的文件夹结构:
root
+ com
- classes
- class1.as
- class2.as
- other
- otherClass.as
+ folder1
- file.swf
- index.swf
我想从 com/classes/
从 index.swf
导入一个类我会这样做:
导入com.classes.class1;
导入com.other.otherClass;
我导入没有问题,但是当我对 file.swf
(位于子文件夹中)执行相同操作时,找不到该类。
那么,如果路线是:../com/classes/class1.as
,我如何导入file.swf
class1.as
I have seen similar questions, but not this specific problem
I have a folder structure like this:
root
+ com
- classes
- class1.as
- class2.as
- other
- otherClass.as
+ folder1
- file.swf
- index.swf
I want to import a class from com/classes/
From index.swf
I would do:
import com.classes.class1;
import com.other.otherClass;
And I have no problem importing, but when I do the same on file.swf
(which is in a subfolder), the class can't be found.
So, how can I import in file.swf
class1.as
if the route is: ../com/classes/class1.as
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用的是 FLash pro,请转到“文件”,然后单击“发布设置”。
单击 Flash 部分 单击 ActionScript 版本旁边的设置按钮。
然后在那里添加你的类路径。
If you were using FLash pro, go to File then Publish Settings.
Click on the Flash section Click on the Settings button beside ActionScript version.
Then add your class path there.
假设
com
和folder1
位于根目录中,则仍然是import com.classes.class1
。根据您使用的 IDE,您可以自动完成此操作。在FlashDevelop中,单击类字符串(例如
new class1();
)并按ctrl+shift+1,它将为您添加导入。在FlashBuilder中,我认为是ctrl+space。如果你使用Flash IDE本身,我不确定是否有命令。 Flash IDE 在编码方面相当糟糕;)考虑另一个开发环境 - 从长远来看,它会为您节省大量时间。尝试 FlashDevelop(免费): http://www.flashdevelop.org/wikidocs/index .php?title=Main_Page
assuming
com
andfolder1
are in the root directory, it's stillimport com.classes.class1
.Depending on the IDE you're using, you can have this done for you automatically. In FlashDevelop, click on the class string (e.g.
new class1();
) and press ctrl+shift+1, and it'll add the import for you. In FlashBuilder, it's ctrl+space I think.If you're using the Flash IDE itself, I'm not sure if there is a command. The Flash IDE is pretty poor when it comes to coding ;) Consider another dev environment - it'll save you a ton of time in the long run. Try FlashDevelop (free): http://www.flashdevelop.org/wikidocs/index.php?title=Main_Page
无法以这种方式导入 SWF 文件中包含的类。您需要使用 Loader 类来实现它。
There's no possibility to import the classes included in SWF file this way. You need to it with Loader class.