Recipe 15.9 Monitoring Load Progress Using a Progress Bar Component

15.9.1 Problem

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

15.9.2 Solution

Use the Progress Bar component.

15.9.3 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 The full URL is:

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.

// This code configures a progress bar named jpegPBar to monitor the load progress of
// a JPEG into a movie clip named myMovieClip_mc.imageHolder_mc.

Here is a complete example showing how to monitor the loading of an MP3:

// Include the file from Chapter 13.
#include ""

// Create the Sound object.
mySound_sound = Sound.createNewSound(  );

// Load an MP3 from the same directory as the Flash movie. Set streaming to false.
mySound_sound.loadSound("myMP3.mp3", false);

// Add the progress bar.
_root.attachMovie("FProgressBarSymbol", "pBar", 1);

// Set the progress bar to monitor the sound.

The progress bar indicates the load progress each time a new chuck of data is received. The perceived smoothness of this depends on the connection speed and latency.

15.9.4 See Also

Recipe 15.11 and Recipe 15.12. See Recipe 15.10 for an alternative approach. You can also find other third-party progress bars by going to the Macromedia Flash Exchange ( and searching for "Progress Bar."

    Part I: Local Recipes
    Part II: Remote Recipes