问题
I have a small framework that I would like to put out there. I would love to export these classes as a single file.
I know there is a SWC format, but there is not much recent information on how to export build this and I have a feeling this format might be outdated.
回答1:
A SWC file is just a ZIP file (with the extension renamed) which, at minimum contains a single SWF movie (the compiled bytecode for your library) and an XML file which provides hinting about the contents of the SWF. However, as a SWC file is just a ZIP file you can add additional information; the most common being including ASDoc output which can then be parsed by IDEs (such as Flash Builder 4) and displayed as in-line documentation.
SWC files are preferred by developers because they are self-contained build dependencies. This makes them easy to manage as you only need to drop a single SWC file into a project to get it to compile. They are also preferred because they discourage junior developers from attempting to make any modifications to the libraries source code (at which point it stops being a 3rd party library).
SWC files can be compiled using the Adobe COMPC utility; most Flash IDE's (Flash Builder, FDT, and FlashDevelop) support compilation of SWCs from the GUI; but you can also compile SWCs from the Command Line, ANT, or Maven.
One thing to watch out for when creating your Framework's SWC file is to externalise any build dependencies that your project has. For example, let's assume that your Framework makes use of the GreenSock Library; instead of compiling your entire framework, including the GreenSock code into a single SWC file, you should instead compile your SWC, excluding all the code contained in your project's dependencies (ie: greensock.swc) and then distribute both your libraries' SWC file and the greensock.swc file - this way, developers that make use of your Framework won't be forced to use the version of the GreenSock Library you compiled against. An example of this practice in action can be found in the RobotLegs framework which distributes both robotlegs.swc and swiftsuspenders.swc.
I've written a blog post about managing build dependencies which may provide related reading on the topic.
Finally, I would reccomend hosting your Libraries source code on a public SCM solution; such at GitHub or Google Code, that way developers can read (and checkout) the source code if they require a reference - it also provides a good central location for issue management and documentation.
来源:https://stackoverflow.com/questions/6041832/what-is-the-best-way-to-distribute-as3-classes-and-packages