Recipe 15.12 Hiding the Graphics and Text for a Progress Bar

15.12.1 Problem

You want to hide the graphics and/or text for a progress bar.

15.12.2 Solution

Set the _visible property of the progress bar instance to false, or use the setDisplayGraphics( ) and/or setDisplayText( ) methods of the progress bar.

15.12.3 Discussion

Progress bars display the loading progress using both graphical and textual means. Although you may want to show both at times, you may want to use the component to monitor the load progress silently?that is, without displaying anything on the screen. Even if you want to display the progress to the user, once the asset has loaded, you generally should turn off the display of the progress bar. In either case, you can easily hide the visual components of the progress bar by setting its _visible property to false:

pBar._visible = false;

Here is some sample code that hides a progress bar once the asset has completed loading:

function onProgress (cmpt) {
  if (cmpt.getPercentComplete(  ) == 100) {
    cmpt._visible = false;

You can hide the graphics and text of the progress bar separately using the setDisplayGraphics( ) and setDisplayText( ) methods. Both methods accept a Boolean parameter, in which true shows the graphics or text and false hides them.

// Add the progress bar. (You must have already added the symbol to your library.)
_root.attachMovie("FProgressBarSymbol", "pBar", 1);

// Hide the graphics.

// Hide the text.

15.12.4 See Also

Recipe 15.9

    Part I: Local Recipes
    Part II: Remote Recipes