| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <!DOCTYPE html |
| PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html lang="en-us" xml:lang="en-us"> |
| <head> |
| <meta name="DC.Type" content="topic"/> |
| <meta name="DC.Title" content="Component compilation"/> |
| <meta name="DC.Format" content="XHTML"/> |
| <meta name="DC.Identifier" content="WS2db454920e96a9e51e63e3d11c0bf69084-79bd_verapache"/> |
| <title>Component compilation</title> |
| </head> |
| <body id="WS2db454920e96a9e51e63e3d11c0bf69084-79bd_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf69084-79bd_verapache"><!-- --></a> |
| |
| <div> |
| <p>When you compile an application, you create a SWF file |
| that a user can download and play. You can also compile any custom |
| components that you create as part of the application.</p> |
| |
| <p>When you create a component, you save it to a location that the |
| Flex compiler can access. You can save your |
| components as MXML and ActionScript files, as SWC files, or as Runtime |
| Shared Libraries (RSLs). You have several options when you compile |
| the components.</p> |
| |
| </div> |
| |
| <div class="nested1" id="WS2db454920e96a9e51e63e3d11c0bf68391-7fff_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf68391-7fff_verapache"><!-- --></a> |
| <h2 class="topictitle2">About compiling</h2> |
| |
| |
| <div> |
| <p>You compile |
| a custom component so that you can use it as part of your application. |
| You can compile the component when you compile the entire application, |
| or you can compile it separately so that you can link it into the |
| application at a later time.</p> |
| |
| </div> |
| |
| <div class="nested2" id="WS2db454920e96a9e51e63e3d11c0bf68391-7ffe_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf68391-7ffe_verapache"><!-- --></a> |
| <h3 class="topictitle3">Flex component file types</h3> |
| |
| |
| <div> |
| <p>When you create a Flex component, you can distribute it |
| in one of several different file formats, as the following table |
| shows:</p> |
| |
| |
| <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"> |
| |
| |
| |
| <thead align="left"> |
| <tr> |
| <th class="cellrowborder" valign="top" width="NaN%" id="d106259e67"> |
| <p>File format</p> |
| |
| </th> |
| |
| <th class="cellrowborder" valign="top" width="NaN%" id="d106259e73"> |
| <p>Extension</p> |
| |
| </th> |
| |
| <th class="cellrowborder" valign="top" width="NaN%" id="d106259e79"> |
| <p>Description</p> |
| |
| </th> |
| |
| </tr> |
| |
| </thead> |
| |
| <tbody> |
| <tr> |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e67 "> |
| <p>MXML</p> |
| |
| </td> |
| |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e73 "> |
| <p>.mxml</p> |
| |
| </td> |
| |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e79 "> |
| <p>A component implemented as an MXML file.</p> |
| |
| </td> |
| |
| </tr> |
| |
| <tr> |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e67 "> |
| <p>ActionScript</p> |
| |
| </td> |
| |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e73 "> |
| <p>.as</p> |
| |
| </td> |
| |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e79 "> |
| <p>A component implemented as an ActionScript |
| class.</p> |
| |
| </td> |
| |
| </tr> |
| |
| <tr> |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e67 "> |
| <p>SWC</p> |
| |
| </td> |
| |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e73 "> |
| <p>.swc</p> |
| |
| </td> |
| |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e79 "> |
| <p>A component implemented as an MXML or ActionScript |
| file, and then packaged as a SWC file. A SWC file contains components |
| that you package and reuse among multiple applications. The SWC |
| file is then compiled into your application when you create the |
| application's SWF file.</p> |
| |
| </td> |
| |
| </tr> |
| |
| <tr> |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e67 "> |
| <p>RSL</p> |
| |
| </td> |
| |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e73 "> |
| <p>.swc</p> |
| |
| </td> |
| |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e79 "> |
| <p>A component implemented as an MXML or ActionScript |
| file, and then deployed as an RSL. An RSL is a stand‑alone file |
| that is downloaded separately from your application's SWF file, |
| and cached on the client computer for use with multiple application |
| SWF files. </p> |
| |
| </td> |
| |
| </tr> |
| |
| </tbody> |
| |
| </table> |
| </div> |
| |
| <p>You must take into consideration the file format and file location |
| when you compile an application that uses the component.</p> |
| |
| </div> |
| |
| </div> |
| |
| <div class="nested2" id="WS2db454920e96a9e51e63e3d11c0bf68391-7ffd_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf68391-7ffd_verapache"><!-- --></a> |
| <h3 class="topictitle3">About compiling with Flex SDK</h3> |
| |
| |
| <div> |
| <p>Flex includes |
| two compilers: mxmlc and compc. You use the mxmlc compiler to compile |
| MXML, ActionScript, SWC, and RSL files into a single SWF file. After |
| your application is compiled and deployed on your web or application |
| server, a user can make an HTTP request to download and play the |
| SWF file on their computer. </p> |
| |
| <p>You use the compc |
| compiler to compile components, classes, and other files into SWC |
| files or into RSLs. </p> |
| |
| <p>You use the compc and mxmlc compilers from a command line. For |
| more information on using the compilers, see <a href="flx_compilers_cpl.html#WS2db454920e96a9e51e63e3d11c0bf69084-7ffd_verapache">Flex |
| compilers</a>.</p> |
| |
| <p>The most basic example of using the mxmlc compiler is one in |
| which the MXML file has no external dependencies (such as components |
| in a SWC file or ActionScript classes). In this case, you open mxmlc |
| and point it to your MXML file:</p> |
| |
| <pre class="codeblock"> $ mxmlc c:/myfiles/app.mxml</pre> |
| |
| <p>The default option is the target file to compile into a SWF file, |
| and it must have a value. If you use a space-separated list as part |
| of the options, you can terminate the list with a double hyphen |
| before adding the target file, as in the following example:</p> |
| |
| <pre class="codeblock"> $ mxmlc -option arg1 arg2 arg3 -- target_file.mxml</pre> |
| |
| </div> |
| |
| </div> |
| |
| <div class="nested2" id="WS2db454920e96a9e51e63e3d11c0bf68391-7ffc_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf68391-7ffc_verapache"><!-- --></a> |
| <h3 class="topictitle3">About case sensitivity during a |
| compilation</h3> |
| |
| |
| <div> |
| <p>The Flex compilers use a case-sensitive file lookup on |
| all file systems. On case-insensitive file systems, such as the |
| Macintosh and Windows file systems, the Flex compiler generates |
| a case-mismatch error when you use a component with the incorrect |
| case. On case-sensitive file systems, such as the UNIX file system, |
| the Flex compiler generates a component-not-found error when you |
| use a component with the incorrect case. </p> |
| |
| </div> |
| |
| </div> |
| |
| <div class="nested2" id="WS2db454920e96a9e51e63e3d11c0bf68391-7ffb_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf68391-7ffb_verapache"><!-- --></a> |
| <h3 class="topictitle3">About the ActionScript source path</h3> |
| |
| |
| <div> |
| <p>Typically, |
| you put component files in directories that are in the ActionScript source |
| path. These include your application's root directory, its subdirectories, and |
| any directory that you specify to the compiler. To specify a directory, |
| you use the <samp class="codeph">source-path</samp> option to the mxmlc compiler. </p> |
| |
| <p>The following rules can help you organize your custom components:</p> |
| |
| <ul> |
| <li> |
| <p>An application can access MXML and ActionScript components |
| in the same directory and in its subdirectories. </p> |
| |
| </li> |
| |
| <li> |
| <p>An ActionScript component in a subdirectory of the main application directory |
| must define a fully qualified package name that is relative to the location |
| of the application's root directory. For example, if you define |
| a custom component in the dir1/dir2/myControls/PieChart.as file, |
| its fully qualified package name must be dir1.dir2.myControls, assuming |
| dir1 is an immediate subdirectory of the main application directory.</p> |
| |
| </li> |
| |
| <li> |
| <p>An MXML component does not include a package name definition. |
| However, you must declare a namespace definition in the file that |
| references the MXML component that corresponds to the directory |
| location of the MXML component, either in a subdirectory of the |
| application's root directory or in a subdirectory of the source |
| path. For more information, see <a href="flx_mxmlcomponents_mxc.html#WS2db454920e96a9e51e63e3d11c0bf69084-7feb_verapache">Simple |
| MXML components</a>.</p> |
| |
| </li> |
| |
| <li> |
| <p>An application can access MXML and ActionScript components |
| in the directories included in the ActionScript source path. The |
| component search order in the source path is based on the order |
| of the directories listed in the source path.</p> |
| |
| </li> |
| |
| <li> |
| <p>An ActionScript component in a subdirectory of a directory |
| included in the source path must define a fully qualified package |
| name that is relative to the location of the source path directory. |
| For example, if you define a custom component in the file dir1/dir2/myControls/PieChart.as, |
| and dir1 is included in the ActionScript source path, its fully |
| qualified package name must be dir1.dir2.myControls.</p> |
| |
| </li> |
| |
| <li> |
| <p>The <samp class="codeph"><fx:Script></samp> tag in the main MXML |
| file, and in dependent MXML component files, can reference components |
| located in the ActionScript source path.</p> |
| |
| </li> |
| |
| </ul> |
| |
| </div> |
| |
| </div> |
| |
| </div> |
| |
| <div class="nested1" id="WS2db454920e96a9e51e63e3d11c0bf68391-7ffa_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf68391-7ffa_verapache"><!-- --></a> |
| <h2 class="topictitle2">Compiling components with Flex |
| SDK</h2> |
| |
| |
| <div> |
| <p>How you compile an application with the Flex SDK is based |
| on how you distribute your custom components that are distributed |
| as MXML, ActionScript, SWC, and RSL files. </p> |
| |
| </div> |
| |
| <div class="nested2" id="WS2db454920e96a9e51e63e3d11c0bf68391-7ff9_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf68391-7ff9_verapache"><!-- --></a> |
| <h3 class="topictitle3">Distributing components as MXML |
| and ActionScript files</h3> |
| |
| |
| <div> |
| <p>When you compile an application with Flex SDK, you define |
| where the MXML and ActionScript files for your custom components |
| exist in the directory structure of your application, or in the |
| directory structure of components shared by multiple applications. </p> |
| |
| <p>For example, you can create a component for use by a single application. |
| In that case, you store it in the directory structure of the application, |
| usually in a subdirectory under the directory that contains the |
| main file of the application. The component is then compiled with |
| the entire application into the resultant SWF file.</p> |
| |
| <p>You can also create a component that is shared among multiple |
| applications as an MXML or ActionScript file. In that case, store |
| the component in a location that is included in the ActionScript |
| source path of the application. When Flex compiles the application, |
| it also compiles the components included in the application's ActionScript |
| source path.</p> |
| |
| <p>You specify the directory location of the shared components by |
| using the following method:</p> |
| |
| <dl> |
| |
| <dt class="dlterm">mxmlc compiler</dt> |
| |
| <dd> |
| <p>Use the <samp class="codeph">source-path</samp> option to the mxmlc |
| compiler to specify the directory location of your shared MXML and |
| ActionScript files. </p> |
| |
| </dd> |
| |
| |
| </dl> |
| |
| </div> |
| |
| </div> |
| |
| <div class="nested2" id="WS2db454920e96a9e51e63e3d11c0bf68391-7ff8_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf68391-7ff8_verapache"><!-- --></a> |
| <h3 class="topictitle3">Distributing components as SWC |
| files</h3> |
| |
| |
| <div> |
| <p>A SWC file is an archive file of Flex components. SWC files |
| make it easy to exchange components among Flex developers. You need |
| to exchange only a single file, rather than the MXML or ActionScript |
| files, images, and other resource files. In addition, the SWF file |
| inside a SWC file is compiled, which means that the code is hidden |
| from casual view. Finally, compiling a component as a SWC file can make |
| namespace allocation an easier process.</p> |
| |
| <p>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 by |
| using WinZip, JAR, or another archiving tool. However, do not manually |
| change the contents of a SWC file, and do not try to run the SWF |
| file that is in a SWC file outside of the SWC file.</p> |
| |
| <p>When you compile your application, you specify the directory |
| location of the SWC files by using the following method:</p> |
| |
| <dl> |
| |
| <dt class="dlterm">mxmlc compiler</dt> |
| |
| <dd> |
| <p>Set the <samp class="codeph">library-classpath</samp> option to the |
| mxmlc compiler to specify the directory location of your SWC files. </p> |
| |
| <p>One |
| of the advantages of distributing components as SWC files is that |
| you can define a global style sheet, named defaults.css, in the |
| SWC file. The defaults.css file defines the default style settings |
| for all of the components defined in the SWC file. For more information, |
| see <a href="flx_mxmlcomponents_mxc.html#WS2db454920e96a9e51e63e3d11c0bf69084-7a00_verapache">Applying |
| styles from a defaults.css file</a>.</p> |
| |
| <p>For more information |
| about SWC files, see <a href="flx_compilers_cpl.html#WS2db454920e96a9e51e63e3d11c0bf69084-7ffd_verapache">Flex |
| compilers</a>. </p> |
| |
| </dd> |
| |
| |
| </dl> |
| |
| </div> |
| |
| </div> |
| |
| <div class="nested2" id="WS2db454920e96a9e51e63e3d11c0bf68391-7ff7_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf68391-7ff7_verapache"><!-- --></a> |
| <h3 class="topictitle3">Distributing components as RSLs</h3> |
| |
| |
| <div> |
| <p>One way to reduce the size of your application's |
| SWF file is by externalizing shared assets into stand-alone files |
| that can be separately downloaded and cached on the client. These |
| shared assets are loaded by any number of applications at run time, |
| but must be transferred to the client only once. These shared files |
| are known as Runtime Shared Libraries (RSLs).</p> |
| |
| <p>If you have multiple applications but those applications share |
| a core set of components or classes, your users download those assets |
| only once as an RSL. The applications that share the assets in the |
| RSL use the same cached RSL as the source for the libraries as long |
| as they are in the same domain. By using an RSL, you can reduce |
| the resulting file size for your applications. The benefits increase as |
| the number of applications that use the RSL increases. If you only |
| have one application, putting components into RSLs does not reduce |
| the aggregate download size, and may increase it.</p> |
| |
| <p>When you compile your application, you specify the directory |
| location of an RSL file by using the following method:</p> |
| |
| <dl> |
| |
| <dt class="dlterm">mxmlc compiler</dt> |
| |
| <dd> |
| <p>Set the <samp class="codeph">external-library-path</samp> option to |
| the mxmlc compiler to specify the location of the RSL file at compile |
| time. Set the <samp class="codeph">runtime-shared-libraries</samp> option to |
| the mxmlc compiler to specify the relative location of the RSL file |
| when the application is deployed. </p> |
| |
| <p>For more information, including |
| information on how to create an RSL file, see <a href="flx_rsl_rsl.html#WS2db454920e96a9e51e63e3d11c0bf69084-7fd1_verapache">Runtime |
| Shared Libraries</a>.</p> |
| |
| </dd> |
| |
| |
| </dl> |
| |
| </div> |
| |
| </div> |
| |
| <div class="nested2" id="WS2db454920e96a9e51e63e3d11c0bf68391-7ff6_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf68391-7ff6_verapache"><!-- --></a> |
| <h3 class="topictitle3">Example: Compiling a custom formatter |
| component</h3> |
| |
| |
| <div> |
| <p>The example in this section uses a custom formatter component |
| that is defined as an ActionScript file. The name of the formatter |
| is MySimpleFormatter, and it is defined in the file MySimpleFormatter.as. |
| For more information on creating customer formatter components, |
| see <a href="flx_createformatters_cf.html#WS2db454920e96a9e51e63e3d11c0bf69084-7a04_verapache">Custom |
| formatters</a>. </p> |
| |
| <p>The process for compiling an MXML file is the same as for an |
| ActionScript file. For an example of deploying an MXML file, see <a href="flx_mxmlcomponents_mxc.html#WS2db454920e96a9e51e63e3d11c0bf69084-7feb_verapache">Simple |
| MXML components</a>.</p> |
| |
| </div> |
| |
| <div class="nested3" id="WS2db454920e96a9e51e63e3d11c0bf68391-7ff5_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf68391-7ff5_verapache"><!-- --></a> |
| <h4 class="topictitle4">Distributing a component as an |
| ActionScript file</h4> |
| |
| |
| <div> |
| <p>When |
| you distribute a component defined as an ActionScript file, you |
| can store it within the same directory structure as your application |
| files or in a directory specified in the ActionScript source path.</p> |
| |
| <p>The MXML tag name for a custom component consists of two parts: |
| the namespace prefix and the tag name. The namespace prefix tells |
| Flex where to look for the file that implements the custom component. |
| The tag name corresponds to the filename of the component, in this |
| case MySimpleFormatter.as. Therefore, the file MySimpleFormatter.as |
| defines a component with the tag name of <samp class="codeph"><</samp> |
| <em>namespace</em> |
| <samp class="codeph">:MySimpleFormatter></samp>.</p> |
| |
| <p>The main application MXML file defines the namespace prefix used |
| to reference the component in the <samp class="codeph"><s:Application></samp> tag. |
| When you deploy your formatter as an ActionScript file, you refer |
| to it in one of the following ways:</p> |
| |
| <ol> |
| <li> |
| <p>If you store the formatter component in the same directory |
| as the application file, or in a directory that the ActionScript |
| source path (not a subdirectory) specifies, you define the formatter |
| by using an empty <samp class="codeph">package</samp> statement, as the following |
| example shows:</p> |
| |
| <pre class="codeblock"> package |
| { |
| //Import base Formatter class. |
| import mx.formatters.Formatter |
| |
| public class MySimpleFormatter extends Formatter { |
| ... |
| } |
| }</pre> |
| |
| <p>You can refer to it as the following example shows. |
| In the following code, the local namespace (*) is mapped to the |
| prefix MyComp.</p> |
| |
| <pre class="codeblock"> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| xmlns:mx="library://ns.adobe.com/flex/mx" |
| xmlns:MyComp="*"> |
| |
| <strong><MyComp:MySimpleFormatter/></strong> |
| |
| </s:Application></pre> |
| |
| <p>If the same file exists in |
| the ActionScript source path directory and the application directory, |
| Flex uses the file in the application directory.</p> |
| |
| </li> |
| |
| <li> |
| <p>If you store the formatter component in a subdirectory of |
| the directory that contains the application file, you specify that |
| directory as part of the <samp class="codeph">package</samp> statement, as |
| the following example shows:</p> |
| |
| <pre class="codeblock"> <strong>package myComponents.formatters</strong> |
| { |
| //Import base Formatter class |
| import mx.formatters.Formatter |
| |
| public class MySimpleFormatter extends Formatter { |
| ... |
| } |
| }</pre> |
| |
| <p>In this example, the MySimpleFormatter.as file |
| is located in the myComponents/formatter subdirectory of the main |
| application directory. You map the myComponents.formatters namespace |
| to the <samp class="codeph">MyComp</samp> prefix, as the following example |
| shows:</p> |
| |
| <pre class="codeblock"> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| xmlns:mx="library://ns.adobe.com/flex/mx" |
| xmlns:MyComp="myComponents.formatters.*"> |
| |
| <strong><MyComp:MySimpleFormatter/></strong> |
| |
| </s:Application></pre> |
| |
| <p>If multiple files with the |
| same name exist under an ActionScript source path subdirectory and |
| the application subdirectory, Flex uses the file under the application |
| subdirectory.</p> |
| |
| </li> |
| |
| <li> |
| <p>If you store the formatter component in a subdirectory of |
| the ActionScript source path directory, you specify that subdirectory |
| as part of the <samp class="codeph">package</samp> statement, as the following |
| example shows: </p> |
| |
| <pre class="codeblock"> <strong>package flexSharedRoot.custom.components</strong> |
| { |
| //Import base Formatter class. |
| import mx.formatters.Formatter |
| |
| public class MySimpleFormatter extends Formatter { |
| ... |
| } |
| }</pre> |
| |
| <p>You then use a namespace that specifies the subdirectory. |
| The following code declares a component that is in the flexSharedRoot/custom/components directory:</p> |
| |
| <pre class="codeblock"> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| xmlns:mx="library://ns.adobe.com/flex/mx" |
| xmlns:MyComp="flexSharedRoot.custom.components.*"/> |
| |
| <strong><MyComp:MySimpleFormatter/></strong> |
| |
| </s:Application></pre> |
| |
| <p>If the same file exists in |
| the ActionScript source path directory and the application directory, |
| Flex uses the file in the application file directory.</p> |
| |
| </li> |
| |
| </ol> |
| |
| </div> |
| |
| </div> |
| |
| <div class="nested3" id="WS2db454920e96a9e51e63e3d11c0bf68391-7ff4_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf68391-7ff4_verapache"><!-- --></a> |
| <h4 class="topictitle4">Distributing a component as a SWC |
| file</h4> |
| |
| |
| <div> |
| <p>To create a SWC file, use the compc compiler in the <em>flex_install_dir</em>/bin |
| directory. The compc compiler generates a SWC file from MXML component |
| source files and/or ActionScript component source files. </p> |
| |
| <p>In this example, you create a SWC file for a custom formatter |
| component that you defined by using the following package and class |
| definition:</p> |
| |
| <pre class="codeblock"> <strong>package myComponents.formatters</strong> |
| { |
| //Import base Formatter class. |
| import mx.formatters.Formatter |
| |
| public class MySimpleFormatter extends Formatter { |
| ... |
| } |
| }</pre> |
| |
| <p>In this example, the MySimpleFormatter.as file is in the directory |
| c:\flex\myComponentsForSWCs\myComponents\formatters. </p> |
| |
| <p>You use the following compc command from the <em>flex_install_dir</em>/bin |
| directory to create the SWC file for this component:</p> |
| |
| <pre class="codeblock"> .\compc -source-path c:\flex\myComponentsForSWCs\ |
| -include-classes myComponents.formatters.MySimpleFormatter |
| -o c:\flex\mainApp\MyFormatterSWC.swc</pre> |
| |
| <p>In this example, you use the following options of the compc compiler:</p> |
| |
| |
| <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"> |
| |
| |
| <thead align="left"> |
| <tr> |
| <th class="cellrowborder" valign="top" width="NaN%" id="d106259e709"> |
| <p>Option name</p> |
| |
| </th> |
| |
| <th class="cellrowborder" valign="top" width="NaN%" id="d106259e715"> |
| <p>Description</p> |
| |
| </th> |
| |
| </tr> |
| |
| </thead> |
| |
| <tbody> |
| <tr> |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e709 "> |
| <p> |
| <samp class="codeph">-source-path</samp> |
| </p> |
| |
| </td> |
| |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e715 "> |
| <p>Specifies the base directory location of |
| the MySimpleFormatter.as file. It does not include the directories that |
| the component's package statement defines.</p> |
| |
| </td> |
| |
| </tr> |
| |
| <tr> |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e709 "> |
| <p> |
| <samp class="codeph">-include-classes</samp> |
| </p> |
| |
| </td> |
| |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e715 "> |
| <p>Specifies classes to include in the SWC |
| file. You provide the class name (MyComponents.formatters.MySimpleFormatter) |
| not the filename of the source code. All classes specified with |
| this option must be in the compiler's source path, which is specified |
| in the <samp class="codeph">source-path</samp> compiler option. </p> |
| |
| <p>You |
| can use packaged and unpackaged classes. To use components in namespaces, |
| use the <samp class="codeph">include-namespaces</samp> option.</p> |
| |
| <p>If the |
| components are in packages, use dot (.) notation rather than slashes |
| to separate package levels. </p> |
| |
| </td> |
| |
| </tr> |
| |
| <tr> |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e709 "> |
| <p> |
| <samp class="codeph">-o</samp> |
| </p> |
| |
| </td> |
| |
| <td class="cellrowborder" valign="top" width="NaN%" headers="d106259e715 "> |
| <p>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.</p> |
| |
| </td> |
| |
| </tr> |
| |
| </tbody> |
| |
| </table> |
| </div> |
| |
| <p>In your main application file, you specify the component's namespace, |
| as the following example shows:</p> |
| |
| <pre class="codeblock"> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| xmlns:mx="library://ns.adobe.com/flex/mx" |
| xmlns:MyComp="myComponents.formatters.*"> |
| |
| <strong><MyComp:MyFormatter/></strong> |
| |
| </s:Application></pre> |
| |
| <p>When you distribute SWC files, ensure that the corresponding |
| ActionScript file is not in the directory structure of the application |
| or in the ActionScript source path. Otherwise, Flex might use the |
| ActionScript file, rather than the SWC file.</p> |
| |
| <p>When you use mxmlc to compile the main application, ensure that |
| the c:\flex\mainApp directory is included in the library path; otherwise, |
| mxmlc cannot locate the SWC file. </p> |
| |
| <p>For more information about SWC files, see <a href="flx_compilers_cpl.html#WS2db454920e96a9e51e63e3d11c0bf69084-7ffd_verapache">Flex |
| compilers</a>. </p> |
| |
| </div> |
| |
| </div> |
| |
| <div class="nested3" id="WS2db454920e96a9e51e63e3d11c0bf68391-7ff3_verapache"><a name="WS2db454920e96a9e51e63e3d11c0bf68391-7ff3_verapache"><!-- --></a> |
| <h4 class="topictitle4">Distributing a component as an |
| RSL file</h4> |
| |
| |
| <div> |
| <p>You create an RSL by using the compc tool, and then pass |
| the library's location to the compiler when you compile your application. |
| For more information, including an example, see <a href="flx_rsl_rsl.html#WS2db454920e96a9e51e63e3d11c0bf69084-7fd1_verapache">Runtime |
| Shared Libraries</a>.</p> |
| |
| </div> |
| |
| </div> |
| |
| </div> |
| |
| <div> |
| <p><strong>Navigation</strong></p> |
| <p><a href="index.html">Using Flex</a> » <a href="flx_p8a_custom_components.html">Custom components</a></p> |
| </div> |
| |
| <p>Adobe and Adobe Flash Platform are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries and are used by permission from Adobe. No other license to the Adobe trademarks are granted.</p> |
| |
| </div> |
| |
| |
| </body> |
| </html> |