Search code examples
actionscript-3flashswc

How could I convert an existing SWF file to an SWC for using as a library?


I am new to the ActionScript world and I bumped into a problem that is hard for me. I have an SWF file that contains some classes that I cannot recompile from source but want to use again in a different project. I see that SWC files are containing compiled classes that can be easily reused. My question is how could I convert the existing SWF file to an SWC file so that I can use it as a regular library? Google did not help me.


Solution

  • SWC files use ZIP compression, and actually contain a SWF. If you change the file extension from .swc to .zip you can browse the contents and directory structure. It looks like this:

    foobar.swc
        -> catalog.xml
        -> library.swf
    

    With some reverse engineering, you might be able to create a SWC from a SWF by building the catalog.xml file and packing them together in ZIP file.

    But that seems rather complex! You could also simply load the external SWF into your own SWF using Loader. All of the classes, symbols, and timelines of the external SWF will then be available. Of course, this creates a run-time dependency.