Check out "Do you speak JavaScript?" - my latest video course on advanced JavaScript.
Language APIs, Popular Concepts, Design Patterns, Advanced Techniques In the Browser

How to generate SWC file from ActionScript package

SWC file format is really useful when you want to transfer or to compact your ActionScript libraries. It is also used for exporting assets, which can be used later. Let's imagine that you want to create a .swc file for only small part of your application, i.e. pure .as files. I searched a lot for the fastest and easier solution and finally I think that the usage of compc.exe is the best option.

My operating system is Windows so I created the following .bat file:

cd D:\\Flex\\flex_sdk_3.4\\bincompc.exe -output "D:\\swc\\MetadataParser.swc" -source-path "D:\\libraries\\" -include-classes com.krasimirtsonev.data.metadata.MetadataParser

The first line points us to the FLEX SDK (you can download it from here) bin folder. The second line is the usage of the compc.exe. It accepts several parameters, but I think that the most important are:-output - the output path to the generated swc file-source-path - the path to your library classes-include-classes - there is no need to describe all the classes from your package here. In the example above I included only MetadataParser, but it also needs several other classes that are located in other packages (i.e. it contains several import statements) and be sure that they will be added to the generated .swc file too.

If you enjoy this post, share it on Twitter, Facebook or LinkedIn.