Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Master the Time-saving Power of Flash Components, Part 2 : Page 5

In part 1 of this series, you learned to build components that worked with multiple versions of Flash. In this follow-up you'll learn all the little extras that allow you to customize, extend, and distribute your components, for maximum ease and peace of mind.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Step 10: Packaging the Component with the Extension Manager
You've already seen how to manually install your component for testing, but that's not a practical way of distributing your work to others. Instead, you can package the assets into an .mxp file that the Extension Manager can install and uninstall for you.

The Macromedia Extension Manager is a utility that intelligently installs application-specific extensions—such as actions, components, and other enhancements—to Macromedia Studio applications such as Flash, Dreamweaver, Fireworks, and Freehand.

To package your component, the first thing you want to do is go back to the "Component Definition..." window and, when you're sure you're finished testing, switch your Live Preview and Custom UI files to embedded. This means you only have to distribute one FLA file, rather than also including multiple external SWF files.

Figure 3. Tidy Library: This is what your tidied Library should look like before packaging your extension. Note that all the necessary parts are enclosed in one folder (in this case 'FMA Stamper'). This lone, organized folder will appear in the end-user's file when dragging in your component from their Components palette.
The next thing is to clean up your Library. The component will be installed along with any parent and sibling folders. So, it's nice to tidy that arrangement up so the user gets one new folder in his/her library. I start with a parent folder, and then inside that I include the component, the FCustomIcons folder (with icon) if desired, and any assets required. For example, the Stamper requires two MovieClips. I put those into an "art" folder.

Once you've tidied up (see Figure 3), create an instruction file for the Extension Manager so it knows which files to include in the .mxp bundle. This is called an MXI file. It is a simple XML file that includes name and version information about your component, compatible/required products, descriptions about the component and where it can be found inside Flash, and paths to any files you may be including. In this example, shown in Listing 2), you will include the FLA and XML files you created.

As you can see, this file contains environment variables that tell the Extension Manager where to install your files. You can learn more about the MXI file used by the Extension Manager by consulting Macromedia's reference, "The MXI File Format." You'll find a link in the Related Resources section (see left column).

Once the MXI file is complete and well-formed, you can open the file in the Extension Manager. Use the "Package Extension…" command from the File menu. This will prompt you to save the newly packaged extension as an .mxp file that the Extension Manager can use to install the package where you've directed.

Adding Component at Runtime
The last item related to the example is adding the component to a movie at runtime. This is accomplished the same way you would add any MovieClip dynamically, with one exception: You must set the values of the component parameters with a property list in an optional third parameter of attachMovie().

Earlier, when you learned about registering your component class using its Linkage ID, you added a Linkage ID of "stamper" to your component. So, to add Stamper to your movie dynamically, your code would look like this:

attachMovie("stamper","myStamper",1000, {sBackAlpha: 50})

The first value is the aforementioned Linkage ID, the second is the new name of this instance, and the third is the level in which the new instance should appear. There's nothing new so far. The last value, however, is the property list that sets the parameters of the component. You only have one parameter, so it's quite simple.

What's Next?
I hope this has been clear and that you now feel as though you can develop your own components. If you think about it, send me along examples of your work. I'm interested in hearing about your success and how you've implemented this technique.

Rich Shupe is president of FMA, a full-service multimedia development and training facility based in New York. He is a regular Flash columnist for DevX and coauthor of the upcoming "Flash 8: Projects for Learning Animation and Interactivity" and the upcoming "Learning ActionScript 3.0," (both published by O'Reilly). FMA develops web and disc-based products for clients including McGraw-Hill, Phillips, 20th Century Fox, and Nickelodeon, and trains digital media professionals in Flash, ActionScript, HTML, JavaScript, and more.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date