如何在 ActionScript3 中打包库(.jar 等效?)
我正在 AS3 中创建一个库。在库内部,我使用了一堆不需要向库的最终用户公开的类/包。我只想公开其中一个类。
我想我的问题是:
1)AS3 中的库通常如何分布?
2) AS3 中是否有开发人员可以包含的 .jar 等效项,但只能访问/了解我已声明为公共的类?
谢谢!
I am creating a library in AS3. Inside the library I make use of a bunch of classes/packages that need not be exposed to the end user of my lib. I want to only expose one of these classes.
I guess my questions are:
1) How are libraries commonly distributed in AS3?
2) Is there a .jar equivalent in AS3 that developers can include, but will only have access/knowledge of the classes I've declared as public?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AS3 库称为 SWC。与 JAR 一样,它们只是包含一些元数据的 ZIP 存档。您可以使用 Flash Builder 库项目或 Flex SDK 中的 mxmlc 编译器构建库,例如此处进行了描述。
好的做法是分发 SWC 或源代码。当然有文档或自述文件。
AS3 libraries are called SWCs. Like JARs they are just ZIP archives with some metadata included. You can build libraries either using Flash Builder library projects or mxmlc compiler in Flex SDK which is described for example here.
Good practice is to distribute SWC or source code. With docs or readme file of course.
是的,我们没有被迫使用 Flex,事实上 Adobe 甚至不再正式支持 Flex 作为他们的产品,因为它现在是一个开源 apache 项目。 http://blogs.apache.org/flex/
Flash 编译器本身是开源的,并且免费使用,这就是为什么有许多第三方 IDE 和开发工具也可以生成 SWC 库。编译器只需要 zip 中的特殊 xml 文件即可生成 SWC。因此,如果您想避免按照规范手动执行此操作,只需选择一种 GUI 方式来执行此操作即可。
我认为最流行的一种开源 GUI 方式 atm 是 Flash Develop http://www.flashdevelop.org/< /a> 它有一个插件可以做你想做的事。 http://www.flashdevelop.org/community/viewtopic.php ?f=4&t=2987
强烈推荐这个 IDE,但如果您需要更多跨平台的东西,我推荐 Intellij Idea,它是一个很棒的 as3 和 java ide,因为您知道 jar 文件是什么。
SWC 中的类与主项目的一部分没有什么不同,因此,如果您创建具有公共或私有的 SWC,它将以相同的方式成为公共或私有。老实说,虽然社区中的博客和存储库共享的大多数代码只是原始的 *.as 文件,但对于团队中的共享库来说,swc 很方便,并且可以使其更有组织性。
Yes we are not forced into using flex, in fact Adobe doesn't even support Flex as their product officially anymore as it is now an open-source apache project. http://blogs.apache.org/flex/
The compiler itself for flash is open-source and free to use, that is why there are many third party IDEs and development tools that can also produce SWC libraries. The compiler just requires a special xml file in a zip in order to make a swc. So if you want to avoid doing this manually to the spec its just a matter of choosing a gui way to do this.
One of the most popular one open-source gui ways atm I believe is Flash Develop http://www.flashdevelop.org/ which has a plugin to do what you want. http://www.flashdevelop.org/community/viewtopic.php?f=4&t=2987
This IDE is highly recommended but if you need something more cross platform, I recommend Intellij Idea which is a great as3 and java ide, since you know what jar files are.
The classes in your swc will be no different to being part of your main project so if you create a swc with public or private it will be public or private the same way. To be honest though most code shared by blogs and repositories in the community are just raw *.as files, swc is handy however for shared libraries in a team and can make this more organised.