ActionScript 2.0 Components Language Reference |
|
|
|
| ProgressBar component > ProgressBar.setProgress() | |||
Flash Player 6 (6.0.79.0).
Flash MX 2004.
progressBarInstance.setProgress(completed,total)
completed A number indicating the amount of progress that has been made. You can use the ProgressBar.label and ProgressBar.conversion properties to display the number in percentage form or any units you choose, depending on the source of the progress bar.
total A number indicating the total progress that must be made to reach 100%.
A number indicating the amount of progress that has been made.
Method; sets the state of the progress bar to reflect the amount of progress made when the ProgressBar.mode property is set to "manual". You can call this method to make the bar reflect the state of a process other than loading. For example, you might want to explicitly set the progress bar to zero progress.
The completed parameter is assigned to the value property and the total parameter is assigned to the maximum property. The minimum property is not altered.
The following example sets the progress bar mode to manual and calls setProgress() from the onEnterFrame() function, which is invoked repeatedly at the frame rate of the SWF file. The example sets the minimum value for the progress bar to 100 and the maximum to 200 and marks the progress in increments of 1.
Drag an instance of the ProgressBar component onto the Stage, and enter the instance name my_pb in the Property inspector. Add the following code to Frame 1 of the timeline:
/**
Requires:
- ProgressBar on Stage (instance name: my_pb)
*/
var my_pb:mx.controls.ProgressBar;
//Set progress bar mode
my_pb.mode = "manual";
my_pb.label = "%1 out of %2 loaded";
//minimum numerical value before progress bar increments
my_pb.minimum = 100;
//maximum value of progress bar before it stops
my_pb.maximum = 200;
var increment_num:Number = my_pb.minimum;
this.onEnterFrame = function() {
if (increment_num < my_pb.maximum) {
increment_num++;
//update progress of number incrementing
my_pb.setProgress(increment_num, my_pb.maximum);
trace(increment_num);
} else {
delete this.onEnterFrame;
}
};
|
|
|
|