10 Minutes With Flash: Distributing Custom Components
In a recent "10 Minutes with Flash" article, I covered how to build a custom loader component by using the MovieClipLoader class. Later on, I realized that, after you start building your own components, you might want to give them to other people, perhaps through the Macromedia Flash Exchange, via email, or by carrier pigeon. Whatever the case, you could pass off your compiled SWC file and leave it at that. Of course, everyone you send it to will have to know where to put it in the Flash MX 2004 installation directory so they can access it via the Components panel. But I'm sure everyone you could possibly give it to knows how to do that, right?
If your friends are all really that geeky, you have nothing to worry about, except that they might mock you during your next Saturday night viewing of The Matrix for not packaging the component before you sent it to them. In any case, you should try out my new mantra, "Be like me, and give them an MXP." (Like it? I made it up all by myself.)
MXP files are packages for components and other extensions, and are used to install extensions via the Macromedia Extension Manager. (If you don't have the Extension Manager, get it here: http://www.macromedia.com/exchange/em_download/. You'll need it to complete this tutorial.) Just like with other software, you simply double-click on the file icon and the installation process magically begins.
So, you wanna see how to make an MXP file? I thought so.
More Meaningless Acronyms
In case you don't have enough acronyms in your life, I want to add a couple more to your geek dictionary: MXI and MXP. See, to complete this tutorial, we'll use an FLA to export a SWC and use XML to create an MXI file, which in turn will be used to package the SWC into an MXP.
To get started, we'll open up the FLA for the aforementioned percentage loader and export the component as an SWC. To join in the fun, download Percentage_Loader.fla and save it to your desktop.
Open Percentage_Loader.fla in Flash MX 2004 or Flash MX Professional 2004 (Flash Pro).
Open the Library (Ctrl/Cmd+L). You should see nothing in the library but a lonely little Percentage Loader component, as shown in Figure 1. Note that the name of the component in the library is also the name that appears in the Components panel. When you package your own components, be sure to use easy-to-understand names. Using catchy or super-cool component names decreases the odds that someone will actually use your component. Users need to be able to tell what it does from its name.
Right-click on the component and choose Export SWC File. The Export File dialog box appears.
In the dialog box, name your file Percentage Loader.swc and save it to your desktop.
Figure 1 A lonely component, begging to be packaged.
With the component wrapped up in a nice tidy SWC file, we're ready to create a package for it.