Packaging a component is one of the most useful features of components, especially when you want to distribute it to others, perhaps within your company. The process involves creating an XML file, although with a different extension, which is then used by the Macromedia Extension Manager to create an MXP file. When a user opens the MXP file, it will install a component or components into the Components panel. You will need to make a small change to the component you want to include with the MXP package.
|On the CD|| |
The XML file you need to create has a specific format to it, and it is not even of XML file type. The Extension Manager processes MXI files to create MXP files. Fortunately, you do not need to know anything about XML or anything related to it to create an MXI file. In the Chapter 11 folder on the CD, you will find a file named MXI_Template.mxi, which is a simple template for you to enter your own information into. Drag a copy of the file to your computer so that you can edit it. If you do not have any software in which to edit XML files, you can open a simple text editor and drag the file into the editor, as shown in Figure 11.10.
Once you are looking at the XML code, the first thing you need to change is the line that currently looks like this:
name = "Component Set Name"
The attribute name specifies the name of the component or set of components, which is displayed only in the Extension Manager. In the context of the RandomSquares component, you should set this value to Random Squares Component.
The next value you will edit is a node that allows you to put your name on the component. The author's name shows up in the last column of the Extension Manager, and it is important if you are going to distribute your component over the Internet. To set the author name, find the following line and edit it as you see fit.
<author name = "Author Name"/>
The lines underneath the author's name allow you to provide a short description of what your component does, which is shown in the Extension Manager when a user clicks on your component. To change the default description, edit the string between the quotation marks of the following line:
<![CDATA[Description of the component that shows up in the Extension Manager.]]>
Finally, you must specify which components are being added to the Components panel. You do this by providing the file path to the FLA that contains your component or components. Then every component in the FLA is packaged into the MXP file. The divisions in the drop-down menu of the Components panel are determined by the name of the FLA that holds your components. Specify the component FLA by editing the line that currently looks like this:
<file source = "ComponentSet.fla"
You are now finished editing the MXI file. Before you can create the MXP file, you must open the RandomSquaresComponent.fla file to make one small change. In the library, right-click the component and select Component Definition. At the bottom of the dialog box, click the check box labeled Display In Components Panel and type the name of your component into the Tool Tip Text field, as shown in Figure 11.11.
Figure 11.11: Make sure to allow the component to be displayed in the Component panel.
Checking the option makes the component appear in the Components panel when installed by an MXP, and the text field specifies the tool tip text that appears when you hover over a component in the Components panel. Once you have made these changes, save the FLA and close Flash. Be sure that all windows of Flash are closed before you continue.
Now you can double-click the MXI file to open the Extension Manager, in which you will be prompted to choose a name for the MXP file that will be compiled from the MXI file, as shown in Figure 11.12.
Figure 11.12: Create the MXP file by double-clicking the MXI file and selecting the name of the MXP package.
It is the MXP file, and not the MXI file, that you will distribute to whomever you want to have your component. So choose a name and click OK, and the Extension Manager will create the MXP file for you. If you wish to test your work, double-click the MXP file and install your component. It should appear in the Components panel just as in Figure 11.13.
Figure 11.13: After you open the MXP file of the component, it should appear in the Components panel.
Obviously, your work is done in packaging your component. Be sure to keep in mind that you can put as many components into an FLA as you want and package them all in an MXP file. It simply means that there will be more components in a particular division in the Components panel. It is not uncommon for a company to build a large component library over the years and distribute MXP files of all resources to the company's employees.