25 August 2010
A SWC file is an archive file, sometimes also referred to as a class library, for Adobe Flex components and other assets. SWC files contain a SWF file and a catalog.xml file, in addition to properties files and other uncompiled assets, such as CSS files. The SWF file implements the compiled component or group of components and includes embedded resources as symbols. Flex applications extract the SWF file from a SWC file and use the SWF file's contents when the application refers to resources in that SWC file. The catalog.xml file lists the contents of the component package and its individual components.
In most cases, the symbols defined in the SWF file that are referenced by the application are embedded in the Flex application at compile-time. This is known as static linking. The application compiler includes only those classes that are used by your application, and dependent classes, in the final SWF file.
You can also dynamically link the contents of SWC files. Dynamic linking is when the entire SWF file is loaded at runtime. To achieve dynamic linking of the SWF file, you must use the SWC file as a Runtime Shared Library (RSL). For more information, see Using Runtime Shared Libraries in the Flex documentation.
SWC files make it easy to exchange components and other assets among Flex developers. You need only exchange a single file, rather than the MXML or ActionScript files and images and other resource files. The SWF file in a SWC file is compiled, which means that the code is loaded efficiently and is hidden from casual view. Also, compiling a component as a SWC file can facilitate namespace allocation.
When you distribute your components to other developers, you can include the following instructions so that they can install and use them immediately.
To import a SWC file, follow these steps:
The component's icon will appear in the Components panel.
To use SWC files in your Flex projects, you have to add them to the project's library path. The SWC files can be located in the project, a Flex library project, a shared folder within the workspace, or any other location that has been linked to the project—using a shared folder that was added to the project's source path, for example.
When you use SWC files in applications, there are configuration options that determine whether they are statically or dynamically linked to the application, merged into the application SWF file, or external to it and accessed separately at runtime.
For more information about working with SWC files, read the section titled Using your Flash project in Flex in Combining animation and ActionScript using Flash Professional CS5 and Flash Builder 4.