Preloading mp3s in array...using one loading indicator?
I've got a file that uses several mp3 files that I want to preload before starting and I can't get it working...
Here's the code...anyone see a problem? It "looks" like it works locally, but, as soon as I upload it, it doesn't work...I'm hard-coding the file size for the percentage because I want the progress bar to use the size from all the loaded mp3s (3.1 MB)...
Code:
//array of audio files
var my_array:Array = new Array("music", "aud1", "aud2", "aud3", "aud4", "aud5", "aud6", "aud7", "aud8");
var k:Number = 0;
//var tracks total bytes loaded
var sizeLoaded:Number = 0;
//starts the first sound loading
var my_audio:Sound = new Sound();
my_audio.loadSound("audio/"+my_array[k]+".mp3",false);
my_audio.setVolume(0);
//this clip has the progress bar (loadbar) and text display (percentage)
audioLoader_mc.onEnterFrame = function() {
if (k<my_array.length-1) {
if (((my_audio.getBytesLoaded()/my_audio.getBytesTotal())*100)>99) {
sizeLoaded+=sizeLoaded+my_audio.getBytesTotal();
k++;
var my_audio:Sound = new Sound();
my_audio.loadSound("audio/"+my_array[k]+".mp3",false);
my_audio.setVolume(0);
} else {
this.loadbar._width = (sizeLoaded+my_audio.getBytesLoaded()/3100000)*100;
percentage = (sizeLoaded+my_audio.getBytesLoaded()/3100000)*100;
}
} else {
delete this.onEnterFrame();
this._parent.gotoAndPlay("label1");
}
};