How to package library in ActionScript3 (.jar equivalent?) - actionscript-3

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.

Related

Java decompilers that support renaming and other IDE features

I've been trying my hand at decompiling dex and jar files with a few decompilers. So far the best one I've used is jadx, and it also comes with a GUI. However, it seems to be read only. Is there a decompiler that allows me to rename variables/methods/classes for obfuscated code, as well as other more advanced IDE features such as find when a class/method/variable is called/accessed?
In my opinion the best way to do that is to decompile the JAR and then import the code in a IDE of your choice.
If you use IntelliJ IDEA you can create a new project, import the JAR as an external lib, and then use the built-in decompiler. You can then set breakpoints etc.

Coming from a Flash Builder background, how can I import a library into IntelliJ IDEA?

the only IDE I've used for many years was Flash Builder. Sadly the 4.7 version is in a poor state, so, I started looking at other IDE's lately.
I'm trying IDEA, but I don't know how to add a library to my project.
In FB it was simple, I go to the compiler settings and I just add a folder or swc. But here, it seems like there are 2 options, one under the "Libraries" tab and other is creating a new module, however, this new module requires a main app, SDK, and a lot of other stuff that doesn't make any sense to have in a library.
So, what is the equivalent of adding a library path here?.
Thanks.
"Libraries" is the correct way to do it. There are two kinds of libraries: libraries and global libraries. Global libraries can configured once and used in every project. Libraries are configured for each project. See http://www.jetbrains.com/idea/webhelp/configuring-project-and-global-libraries.html

Using a .dll file in ActionScript

I need to use a dll file that was created in C# within my FlashBuilder project. I saw that adobe native extensions might be able to be used to incorporate the dll file, but I'm not entirely sure how to make the .ane file from the .dll file. I was wondering if there is an easier way to gain access to the classes and functions inside the dll file within my actionscript code.
Thanks,
Ilithis
Native extensions may only be used if you're working in Adobe Air. You can read more about the topic and find tutorials here.

box2d for flash how to compile its examples?

http://box2dflash.sourceforge.net/
i downloaded the code and in its folder there is a examples folder. How can i compile them ? what are the other software i need and how can i do it? Please help me because iam completely new to the actionscript programming side.
It is explained in the Examples/Readme.txt
As quoted from the Readme
//
To compile the demo:
//
Flash: extract Box2DFlashAS3 and open
PhysTest.fla in Flash CS3 (9) and hit
Ctrl+Enter.
Flex: Create a new
ActionScript project and add all the files from the archive to the project.
Set Main.as to the default application and hit Ctrl+F11.
MXMLC: From the
"Examples" directory, run: mxmlc
-source-path=../Source/ Main.as;
Thus you have three different ways to compile.
Use Flash CS3 (or higher)
Use Flex Builder (or higher )
Use the Flex SDK that contains mxmlc
Only posting this as an answer because I can't post a comment... this is an alternative box2D implementation that uses alchemy (so much faster) but the real up-side to it is that it has plugins for the flash UI to visually design/create physical objects, including building worlds etc. Video tutorial explains where to download:
http://gotoandlearn.com/play.php?id=135

Flash ActionScript 3.0 - Any free compiler, tools and tutorials?

I have got an assignment in which I have to implement a AS3 wrapper for any FLV player and I have to expose actionscript functions (External Interfaces?) so that other can be used in other different applications via CallFunction API. I have few questions regarding this -
Are the tools for this are freely available? I know Flex SDK is but I want standalone swf (I means Flash Player 10) that can be used anywhere without any dependency and should contain FLV player embedded or should be able to load it from a particular location by supplying the URL.
Is it possible only with an ActionScript compiler (or any free tools?). My problem is that I don't have flash or flex builder and I don't want to spend money on these because I don't work on it.
As I have almost zero knowledge about it. Can you guys please explain me (if possible with details) that what I need to do. Any resoures on how to create and compile?
If any of you have ever done this it would be really great if you guys can share samples. I've heard that many people have done the same thing for video players.
I can share a bit of my setup
I use Flash (CS5) for creating assets
I use FlexSDK as the compiler
And do all the code in FlashDevelop
Flashdevelop is for PC only for now, it's free and comes since the last few versions now with a debugger
I use FlexSDK to compile and Eclipse with AS IDE or something along those lines, and then preview things in a web browser using an html page with the swf file embedded.
check out projectsprouts. its a pretty nice Flash (as2/3/Flex/AIR) generation tool that can help you stub out your project, compile it, and even create unit tests if you want. pretty simple ruby install (i am a ruby newb, and got is running pretty easily). It was a pretty good support base, and an active mailing list where people will be happy to help you along.
It is important to note that the FlexSDK has very little to do with Flex unless you are linking against classes that are Flex specific. mxmlc does not have anything to do with MXML even though it will also compile MXML.
Here is an article that describes Flash development on Linux. It is pretty old, but the principles are the same. With an Actionscript 3 Compiler (contained in the FlexSDK) and a text editor, you are off to the races. It is a lot easier with Flash Builder 4, FDT 4, Intellij IDEA, Flash Develop, etc ;)