Start Flash. Click "File," "New." Click the file type "Flash File(ActionScript 3.0)" from the "New Document" dialog box. Click "OK."
Click "Components" from the "Windows" menu. Click and drag the Progress Bar icon onto the Flash Stage from the Components library. Click "Properties" from the "Windows" men. Type "ProgressBar" into the instance name text box.
Click and drag the button icon onto the Flash stage from the Components library. Type "loadSound" into the instance name text box.
Click "Component Inspector" from the "Windows" menu. Type "Load White Rabbit" in the label text box.
Select "Actions" from the "Windows" menu. Place your cursor on the first line of the "Actions" editor. Click and type this code to import the necessary flash utilities to use the Progress Bar:
import fl.controls.ProgressBar;
import flash.events.ProgressEvent;
Type this code, starting at the next line in the "Actions" editor, to place a TextField on the Flash stage to be used to display the percentage of the MP3 music file downloaded:
var ProgressStatus:TextField = new TextField();
ProgressStatus.x = 200;
ProgressStatus.y = 100;
ProgressStatus.width = 400;
addChild(ProgressStatus);
Type the following code, starting at the next line in the "Actions" editor, to declare a sound object to hold the music file downloaded and to use as the source file for the Progress Bar to monitor loading progress with:
var music:Sound = new Sound();
ProgressBar.source = music;
var musicFilelocation:String = "http://173.192.206.135/cgi-bin/dl.cgi/ze6fl4bvyep6nqwg7fcgcwlb4msqhqpawhws2aeogy/z6ipwi6m53na.mp3";
var musicrequest:URLRequest = new URLRequest(musicFilelocation);
Type the following code, starting at the next line in the "Actions" editor. This will detect when the music file has completed downloading; instruct Flash to begin downloading the music file when the loadSound button has been clicked; update the Progress Bar on the percentage of the file downloaded and begin playing the music file after it has completed downloading.
ProgressBar.addEventListener(ProgressEvent.PROGRESS, progressHandler);
ProgressBar.addEventListener(Event.COMPLETE, soundLoaded_fn);
loadSound.addEventListener(MouseEvent.CLICK, getSound_fn);
function progressHandler(event:ProgressEvent):void {
ProgressStatus.text = ("File Loaded is " + ProgressBar.percentComplete + " Percent Complete");
}
function soundLoaded_fn(event:Event):void {
music.close();
loadSound.enabled = false;
music.play();
}
function getSound_fn(event:MouseEvent) {
music.load(musicrequest);
}
Copy and paste this code into the "Actions" editor to ensure that the Progress Bar program runs error-free:
import fl.controls.ProgressBar;
import flash.events.ProgressEvent;
var ProgressStatus:TextField = new TextField();
ProgressStatus.x = 200;
ProgressStatus.y = 100;
ProgressStatus.width = 400;
addChild(ProgressStatus)
var music:Sound = new Sound();
ProgressBar.source = music;
var musicFilelocation:String = "http://173.192.206.135/cgi-bin/dl.cgi/ze6fl4bvyep6nqwg7fcgcwlb4msqhqpawhws2aeogy/z6ipwi6m53na.mp3";
var musicrequest:URLRequest = new URLRequest(musicFilelocation);
ProgressBar.addEventListener(ProgressEvent.PROGRESS, progressHandler);
ProgressBar.addEventListener(Event.COMPLETE, soundLoaded_fn);
loadSound.addEventListener(MouseEvent.CLICK, getSound_fn);
function progressHandler(event:ProgressEvent):void {
ProgressStatus.text = ("File Loaded is " + ProgressBar.percentComplete + " Percent Complete");
}
function soundLoaded_fn(event:Event):void {
music.close();
loadSound.enabled = false;
music.play();
}
function getSound_fn(event:MouseEvent) {
music.load(musicrequest);
}
Click the "TestMovie" option in the "Control" menu to download the music file and watch the Progress Bar move from left to right as the file is downloaded.