|
|
This .NET utility extracts the names of the classes compiled in a set of swf's, searches a defined classpath to find the referenced classes and copies the .as files found in said classpath to an output folder chosen by the user.
What problem does it try to solve?
Actually, a problem that I've frequently run into in many Flash projects. Often, I place the classes and packages for a project inside a "fla" or "src" folder, so the code is accessible to the fla files, which live in that same folder, without any extra classpath configuration. I also use "common" code from a central repository, as well (the kind of code that is generic enough that can be shared among many projects).
The problem is, when you have to give the sources of the project to someone, in order for them to be able to compile the fla's, you'd either have to give them a copy of your whole central repository (most of which is not relevant or needed to the project at hand), or manually track down which classes are being referenced in your project's code. Then you'd have to create folders that follow the original package/folder layout and manually copy and paste your .as files. A couple of times I had to do that and it was rather painful, time consuming and error prone. So, this project was developed based on my own needs as a way to automatize all that tedious work, and is made available here in the hope that it might help other developers that have come across the same problem.
Status of the project
Currently, this is an alpha version. I've tested it on 3 windows boxes, and it has run without problems or major bugs, so far.
I'm planning some refactoring of the code in the near future to polish it up a bit, and fixing some minor bugs in the user interface. By the way, I'm not an expert in C# so the code might not be very C#esque. Adding comments in English (currently they are in Spanish only) is in my todo-list as well. (The names of variables, methods, classes, etc, are in English, though).
To compile, you need Visual Studio 2003 and Flash 8 (a MTASC version could be implemented if needed). To run it, .NET Framework 1.1 (plus Flash Player 8 for the ActionScript 2.0 version).
If you just want to try out the program but are not interested in the source code or compiling it yourself, you can find a compiled copy of both versions (AS 2.0 & AS 3.0) in the downloads area. Just download it, unrar where you want and run the .exe (no installation needed) ( I've found a bug that occurs when you place AS 3 Class Exporter in your desktop and prevents the program from finding any classes; please choose some other location: see Issue 2 ). I've included a template configuration xml, but you'll have to change the folder paths to adjust them so they point to where your data actually is. You can overwrite that xml or save it with a different name in case you want to reuse it. (More on HowToUseIt)
Structure
The project is divided into 4 Visual Studio solutions
AS Class Exporter (dll)
It's the back-end of the project and contains the core functionality.
There are two versions of the Exporter:
One works with swf's exported for the AVM1 (i.e. Actionscript 1.0 & 2.0). It uses a library developed by iceeLyne (http://icube.freezope.org/extinter/index.htm) to load a helper swf that, in turn, loads the required swf's and extracts a list of the compiled classes. It then passes the list to the C# app, which tries to find the classes in a given classpath, and copy them to an output folder.
The other one works in a very similar way, and is intended to extract classes from swf's exported for the AVM2 (i.e. Actionscript 3.0). Instead of loading a helper swf (I haven't found a way to read the compiled classes from Actionscript 3.0), it uses "abcdump". "abcdump" is dissasembler developed by the Tamarin project. It decodes AVM2 bytecode into a readable text file, which contains the names of the symbols exported in the swf. With that, it's possible to find the name of the exported classes and interfaces. The text file is parsed and then deleted. The rest of the process is the same as in the AVM1 version.
(I'm using a compiled version of abcdump that can be found in this blog post. You might also want to take a look at this other blog post, in English, about abcdump. )
AS2 Class Exporter Front (WinForm)
A GUI front-end to use with swf versions 8,7 & 6 (compiled for the AVM1, Actionscript 1.0 & 2.0).
AS3 Class Exporter Front (WinForm)
A GUI front-end to use with swf version 9 (compiled for the AVM2, Actionscript 3.0). This version is experimental and needs some heavy testing to assure it extracts the classes' names properly.
It won't mess up your file system, though; when copying the .as files to the given output folder, the program will not overwrite any file, as an extra "security" measure; that's a design desition, made in order to prevent accidentally overwriting something in your central repository, in case you mistakenly set the output path to point to your classpath. (The same applies to the AS 2.0 version)
Controls Califa (User Control)
Just a -very rudimentary and improvable- user control, similar to the flash class path control.
