User Guide
Using the ProgressBar component 995
To create an application with the ProgressBar component in manual mode:
1. Drag a ProgressBar component from the Components panel to the Stage.
2. In the Property inspector, do the following:
■ Enter the instance name my_pb.
■ Select Manual for the mode parameter.
3. Select Frame 1 in the Timeline, open the Actions panel, and enter the following code,
which updates the progress bar manually on every file download by using calls to
setProgress():
for (var i:Number = 1; i <= total; i++){
// insert code to load file
my_pb.setProgress(i, total);
}
Following are two more examples.
To create an application with the ProgressBar component in manual mode
(example 2):
1. Drag a Label component onto the Stage and give it an instance name my_label.
2. Drag a ProgressBar component onto the Stage and give it an instance name my_pb.
3. Select the my_pb ProgressBar on the Stage and, in the Property inspector, set the
component's mode parameter to "manual".
4. Select Frame 1 in the Timeline, and add the following ActionScript in the Actions panel:
var feed_xml:XML = new XML();
feed_xml.onLoad = function(success:Boolean):Void {
clearInterval(timer);
my_label.text = "XML Loaded";
my_pb.setProgress(feed_xml.getBytesLoaded(),
feed_xml.getBytesTotal());
};
function updatePB(local_xml:XML):Void {
my_pb.setProgress(local_xml.getBytesLoaded(),
local_xml.getBytesTotal());
}
var timer:Number = setInterval(updatePB, 100, feed_xml);
feed_xml.load("http://www.helpexamples.com/flash/xml/menu.xml");
5.
Press Control+Enter to test.