Exporting components
21
If the component’s ActionScript classes are in a package, you must specify a namespace that points
to that package in your MXML file, as the following example shows:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
xmlns:myp="myPackage.*"
>
<myp:myComponent />
</mx:Application>
For more information on using namespaces for Flex components, see
Developing Flex Applications
.
To pass properties to the component, add them as tag properties, as the following example shows:
<ModalText labelPlacement="left"/>
You can instantiate a custom component by creating the component’s class in ActionScript using
the
createClassObject()
method:
<mx:Script>
<![CDATA[
createClassObject(MyComponent, "myComp", 0, {myName:"Ted"});
]]>
</mx:Script>
The previous example is equivalent to the following MXML statement:
<MyComponent id="myComp" myName="Ted" />
Including debugging information
The SWD file contains debugging information for the SWF file. You must use SWD files to use
the Debug Flash Player to debug your component. By default, Flash does not include debugging
information when exporting the SWC file.
When you export a SWC file, you can include the SWD file in the SWC file by selecting
Debugging Permitted in the Publish Settings dialog box. As with all settings in the Publish
Settings dialog box, you must make this change for every FLA file. It is not a global setting.
Note:
You should not include debugging information in your SWC file if the SWC file is used in a
production environment. It increases the size of the SWC file and also makes debugging information
available to users.
To include the SWD file in your SWC file:
1.
Open your FLA file.
2.
In the Flash environment, select File > Publish Settings.
The Publish Settings dialog box appears.
3.
Select the Debugging Permitted check box.
4.
Click OK.
5.
Save the FLA file.
6.
Export the SWC file as described in
“Creating SWC files” on page 18
.
Flash includes the SWD file with the other files in your SWC file.