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!
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.
Is it possible to create a SWC file without using the Flex framework? I just want bare-bone AS3.
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.
"only have access/knowledge of the classes I've declared as public?"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With