Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 71

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

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:
Option name
-source-path
-include-components
-o
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/>
Description
Specifies the base directory location of the MySimpleFormatter.as
file. It does not include the directories that the component's
package statement defines.
Specifies the component to add to the SWC file, and includes the
information that the package statement specifies.
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.
Compiling components with Flex 2 SDK
71

Advertisement

Table of Contents
loading

Table of Contents