O'Reilly logo

Actionscript Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

15.9. Monitoring Load Progress Using a Progress Bar Component

Problem

You want to display the progress of an asset-loading operation using a progress bar.

Solution

Use the Progress Bar component.

Discussion

The Progress Bar component is included in the Flash UI Components Set 2. You can download this components set for free from the Macromedia Flash Exchange at http://www.macromedia.com/exchange/flash/. The full URL is:

http://www.macromedia.com/cfusion/exchange/index.cfm?view=sn110#loc=en_us&view=sn111&viewName=Flash%20Extension&extID=365880&lc_id=55920

After downloading the components set, install it using the Macromedia Extension Manager (also a free download from the Flash Exchange). You have to restart Flash to see the new components. Once you restart Flash, you should see the Flash UI Components Set 2 option in the Components panel menu.

You can add a progress bar to a movie manually at authoring time, or you can add the Progress Bar component to the movie’s Library and use the attachMovie( ) method to add the component to the movie at runtime:

_root.attachMovie("FProgressBarSymbol", "pBar", 1);

You should use the setLoadTarget( ) method of a progress bar instance to specify a movie clip or a sound that the component should monitor:

// This code configures a progress bar named soundPBar to monitor the load progress
// of a sound named mySound_sound.
soundPBar.setLoadTarget(mySound_sound);

// This code configures a progress bar named jpegPBar to monitor the load progress of // a JPEG ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required