A progress bar lets you display the progress of content as it loads. This is essential feedback for users as they interact with an application.
There are several modes in which to use the ProgressBar component; you set the mode with the mode parameter. The most commonly used modes are event mode and polled mode. These modes use the source parameter to specify a loading process that either emits progress and complete events (event mode), or exposes getBytesLoaded() and getsBytesTotal() methods (polled mode). You can also use the ProgressBar component in manual mode by manually setting the maximum, minimum, and indeterminate properties along with calls to the ProgressBar.setProgress() method.
You can set the following authoring parameters for each ProgressBar instance in the Property inspector or in the Component inspector:
mode is the mode in which the progress bar operates. This value can be one of the following: event, polled, or manual. The default value is event.
source is a string to be converted into an object representing the instance name of the source.
direction indicates the direction toward which the progress bar fills. This value can be right or left; the default value is right.
label is the text indicating the loading progress. This parameter is a string in the format "%1 out of %2 loaded (%3%%)". In this string, %1 is a placeholder for the current bytes loaded, %2 is a placeholder for the total bytes loaded, and %3 is a placeholder for the percent of content loaded. The characters "%%" are a placeholder for the "%" character. If a value for %2 is unknown, it is replaced by two question marks (??). If a value is undefined, the label doesn't display.
labelPlacement indicates the position of the label in relation to the progress bar. This parameter can be one of the following values: top, bottom, left, right, center. The default value is bottom.
conversion is a number by which to divide the %1 and %2 values in the label string before they are displayed. The default value is 1.
You can write ActionScript to control these and additional options for the ProgressBar component using its properties, methods, and events. For more information, see ProgressBar class.
The following procedure explains how to add a ProgressBar component to an application while authoring. In this example, the progress bar is used in event mode. In event mode, the loading content must emit progress and complete events that the progress bar uses to display progress. (These events are emitted by the Loader component. For more information, see Loader component.)
loader.autoLoad = false; loader.contentPath = "http://imagecache2.allposters.com/images/86/ 017_PP0240.jpg"; pBar.source = loader; // loading does not start until load() is invoked loader.load();
In the following example, the progress bar is used in polled mode. In polled mode, the ProgressBar uses the getBytesLoaded() and getBytesTotal() methods of the source object to display its progress.
loader and calls loadSound() to load a sound into the Sound object:
var loader:Object = new Sound();
loader.loadSound("http://soundamerica.com/sounds/sound_fx/A-E/air.wav",
true);
In the following example, the progress bar is used in manual mode. In manual mode, you must set the maximum, minimum, and indeterminate properties in conjunction with the setProgress() method to display progress. You do not set the source property in manual mode.
setProgress():
for(var:Number i=1; i <= total; i++){
// insert code to load file
pBar.setProgress(i, total);
}
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00002688.html
Comments