This site is now just an archive over the rise and fall of Flash. The domain flashmagazine.com is available for sale
Login | Register
Introduction to components

Introduction to components

As of Flash MX, Macromedia introduced the ability to create, distribute, and use third party components. In this article, Mitch Allen will show you how to take advantage of the growing list of available components.

Written by Mitch Allen What is a component?
In Flash MX, a component is a movie clip symbol that houses an object definition (otherwise known as a class). Components can be found in the Component window (Window / Components) of the Flash authoring environment. As with the Library, you can drag components from the Component window on to the stage and create instances of them.

Components in the Component window exist in separate files outside of Flash. They can be packaged and distributed to other Flash programmers using a Macromedia utility called the Macromedia Extension Manager.

Flash UI Components
Flash MX comes with a set of preinstalled components titled Flash UI Components. You can find them in the Components window. Select Window / Components if it's not already available.

If you have other components installed, the Flash UI Components may not be visible in the Component window. To make them visible, drop down the selector and pick "Flash UI Components."

The Flash UI Components that are packaged with Flash include: CheckBox, ComboBox, ListBox, PushButton, RadioButton, ScrollBar, ScrollPane. You can download additional Flash UI components from Macromedia's Web site.

Exercise 01: Using the Flash UI Button Component
In this exercise, you will be shown how to use a pre-existing component.

Create a test function
1. Click on Frame 1, open up the Actions panel, and enter the following:

function test() { trace( "Click!" ); }



Use a Flash UI Component
2. Check: Windows / Components
3. Select in the Components window Flash UI Components
4. Drag a PushButton component on to the stage
5. Open up the Properties window for the component
6. Change the Label text to read: Test the button
7. For Click Handler enter the name of your function: test

Test your movie
8. Select from the main menu: Control / Test Movie
9. Click the button

Macromedia Exchange for Flash
You can obtain more components by visiting the Macromedia Exchange for Flash Web site. The easiest way to get there is to start Flash MX and select Help / Flash Exchange. This will start your Web browser and point to Macromedia's site. You're also free to visit other sites and download third party component packages.

Macromedia Extension Manager and MXP Files
Flash MX components are packaged in .mxp files. In order to install a component package, you must select a .mxp file using the Macromedia Extension Manager.

To install a component package, you run the Extension Manager. From within Flash, select: Help / Manage Extensions... Then select from the Extension Manager's menu: File / Install Extension... and point to the .mxp file.

Exercise 02: Installing a Component
In this exercise, you will need to be connected to the Internet.

One purpose of this exercise is to introduce you to the Macromedia Exchange for Flash Web site. This is not an endorsement. But I felt that it would be helpful to introduce you to the central resource for components.

Macromedia charges for some of their components, but they also list free components from third parties. The objective of the first part of this exercise is to obtain a .mxp file. Macromedia is not the only resource, but it is used in this exercise.

Get an MXP file from Macromedia Exchange
1. Select: Help / Flash Exchange
2. You should now be on the Macromedia Exchange for Flash Web site (It may require you to create a login)
3. Find a component (free or otherwise) and download it to your computer

Use the Macromedia Extension Manager
4. From within Flash, select: Help / Manage Extensions…
5. From within the Extension Manager, select: File / Install Extensions … and select the .mxp file that you downloaded
6. Restart Flash

Test the component
7. Find your new component in the Components window and drag it on to the stage

Review
In this article, you learned about:

- Built-ins (Flash UI)
- Macromedia Exchange for Flash

This article has been adapted from the book Flash MX ActionScript: for Programmers by Mitch Allen (mitch@mitchallen.com) and Priscilla Grogan (editor) (priscilla@sqaoutsource.com) ISBN: 0-9725676-0-7. For more information, please visit http://www.gahitsuPress.com or http://www.mitchallen.com.

 

 

Get new stories first

Click to follow us on Twitter!

 

Comments

No comments for this page.

Submit a comment

Only registered members can comment. Click here to login or here to register