Understanding SWC files

A SWC file is a zip-like file (packaged and expanded by means of the PKZip archive format) generated by the Flash authoring tool.

The following table describes the contents of a SWC file.

File

Description

catalog.xml

(Required) Lists the contents of the component package and its individual components, and serves as a directory to the other files in the SWC file.

Source code

If the component is created with Flash MX 2004, the source code is one or more ActionScript files that contain a class declaration for the component.

The source code is used only for type checking when subclassing components and is not compiled by the authoring tool since the compiled bytecode is already in the implementing SWF file.

The source code may contain intrinsic class definitions that contain no function bodies and are provided purely for type checking.

Implementing SWF files

(Required) SWF files that implement the components. One or more components can be defined in a single SWF file. If the component is created with Flash MX 2004, only one component is exported per SWF file.

Live Preview SWF files

(Optional) If specified, these SWF files are used for Live Preview in the authoring tool. If omitted, the implementing SWF files are used for Live Preview instead. The Live Preview SWF file can be omitted in nearly all cases; it should be included only if the component's appearance depends on dynamic data (for example, a text field that shows the result of a web service call).

Debug info

(Optional) A SWD file corresponding to the implementing SWF file. The filename is always the same as that of the SWF file, but with the extension .swd. If it is included in the SWC file, debugging of the component is allowed.

Icon

(Optional) A PNG file containing the 18 x 18, 8-bit-per-pixel icon used to display a component in the authoring tool user interface(s). If no icon is supplied, a default icon is displayed. (See Adding an icon.)

Property inspector

(Optional) If specified, this SWF file is used as a custom Property inspector in the authoring tool. If omitted, the default Property inspector is displayed to the user.

To view the contents of a SWC file, you can open it using any compression utility that supports PKZip format (including WinZip).

You can optionally include other files in the SWC file, once you have generated it from the Flash environment. For example, you might want to include a Read Me file, or the FLA file if you want users to have access to the component's source code.

Multiple SWC files are expanded into a single directory, so each component must have a unique filename to prevent conflicts.