Macromedia flex 2 Manual

Página de 254
Compiling components with Flex 2 SDK
71
Distributing a component as a SWC file
To create a SWC file, use the compc utility in the flex_install_dir/bin directory. The compc 
utility generates a SWC file from MXML component source files and/or ActionScript 
component source files. 
In this example, you create a SWC file for a custom formatter component that you defined by 
using the following package and class definition:
package myComponents.formatters
{
//Import base Formatter class.
import mx.formatters.Formatter
public class MySimpleFormatter extends Formatter {
...
}
}
In this example, the MySimpleFormatter.as file is in the directory 
c:\flex\myComponentsForSWCs\myComponents\formatters. 
You use the following compc command from the flex_install_dir/bin directory to create the 
SWC file for this component:
.\compc -source-path c:\flex\myComponentsForSWCs\ 
-include-components myComponents.formatters.MySimpleFormatter 
-o c:\flex\mainApp\MyFormatterSWC.swc
In this example, you use the following options of the compc compiler:
In your main application file, you specify the component’s namespace, as the following 
example shows:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
xmlns:MyComp="myComponents.formatters.*">
<MyComp:MyFormatter/>
Option name
Description
-source-path
Specifies the base directory location of the MySimpleFormatter.as 
file. It does not include the directories that the component’s 
package statement defines.
-include-components
Specifies the component to add to the SWC file, and includes the 
information that the package statement specifies. 
-o 
Specifies the name and directory location of the output SWC file. In 
this example, the directory is c:\flex\mainApp, the directory that 
contains your main application.