How to pack a library in ActionScript3 (equivalent to jar?)

I am creating a library in AS3. Inside the library, I use a bunch of classes / packages that should not be accessible to the end user of my library. I only want to expose one of these classes.

I think my questions are:

1) How are libraries commonly distributed in AS3?

2) Is there an .jar equivalent in AS3 that developers can include, but will only have access / knowledge of those classes that I declared public?

Thanks!

+6
source share
2 answers

AS3 libraries are called SWCs. Like JARs, they are only ZIP archives with metadata included. You can create libraries either using Flash Builder library projects, or using the mxmlc compiler in the Flex SDK, which is described, for example, here .

Good practice is to distribute SWC or source code. Of course with documents or readme file.

+5
source

Can I create a SWC file without using the Flex framework? I just want a bare-bone AS3.

Yes, we are not forced to use flex, in fact Adobe does not even support Flex as its product officially, as it is now an open source Apache project. http://blogs.apache.org/flex/

The flash compiler itself is open source and free to use, so there are many third-party IDEs and development tools that can also create SWC libraries. To create swc, the compiler simply requires a special xml file in the zip file. Therefore, if you want to avoid this manually for specification, it is just a matter of choosing a gui method for this.

One of the most popular open source GUI methods, I suppose, 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 great as3 and java ide since you know what jar files are.

"have access / knowledge of only those classes that I declared public?

The classes in your swc will not differ from being part of your main project, so if you create swc with an open or open one, it will be public or private. To be honest, although most of the codes shared by blogs and repositories in the community are only raw * .as files, swc is convenient, but it can make it more organized for shared libraries in a team.

+3
source

Source: https://habr.com/ru/post/907618/


All Articles