View comments | RSS feed

Using SWC files

A SWC file is an archive file for Flex components. SWC files make it easy to exchange components among Flex developers. You need only exchange a single file, rather than the MXML or ActionScript files and images and other resource files. In addition, the SWF file inside a SWC file is compiled, which means that the code is obfuscated from casual view. Finally, compiling a component as a SWC file can make namespace allocation an easier process.

SWC files can contain one or more components and are packaged and expanded with the PKZip archive format. You can open and examine a SWC file using WinZip, jar, or other archiving tool. However, you should not manually change the contents of a SWC file, and you should not try to run the SWF file that is in a SWC file outside of a SWC file.

The following table describes the contents of a SWC file:

File Description

catalog.xml

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

Contains one or more ActionScript files that contain class declarations for the components.

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

The source code might contain intrinsic class definitions that contain no function bodies and are provided only for type-checking.

Implementing SWF files

Implements the components. One or more components can be defined in a single SWF file.

Live Preview SWF files

Supports Live Preview in the authoring tool. If omitted, the implementing SWF files are used for Live Preview instead. You can omit the Live Preview SWF file in nearly all cases; include the file only if the component's appearance depends on dynamic data (for example, a text box that shows the result of a web service call).

Debug info

Includes 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

Contains the 18 x 18, 8-bit-per-pixel icon used to display a component in the authoring tool user interface. If you do not supply an icon, a default icon appears. The icon must be a PNG file.

Property Inspector

Supports a custom Property Inspector in the authoring tool. If omitted, the default Property Inspector is displayed to the user.

Flex includes a single SWC file that contains all the built-in components. This SWC file is located in the flex_app_root/WEB-INF/flex/frameworks directory.


Version 1.5

Comments


sansunzw said on Jul 18, 2005 at 1:10 AM :
how to create a Live Preview swf files into a swc file.
(use compc command)
danger42 said on Jul 18, 2005 at 11:28 AM :
You can only include a Live Preview file in a SWC file if you export the SWC file from the Flash IDE. For information on using the Live Preview feature in Flash MX 2004, see:
http://download.macromedia.com/pub/documentation/en/flash/mx2004/using_flash.pdf

hth
matt horn
flex docs
sansunzw said on Jul 18, 2005 at 10:22 PM :
thank you for your reply

I make a swc file with this command:
compc -root d:/mycom -o d:/test.swc d:/mycom/test.as

In flexbuilder, I want to see the prview in design mode although this component has not any view in run mode.

In flash , I use "_global.isLivePreview" to divide the livepreview and run mode. just like this:
if (_global.isLivePreview)
{
//create a preview here
return;
}
else
{
//destory the preview here
boundingBox_mc._visible = false;
}

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flex/15/flex_docs_en/00000861.htm