A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Problem loading multiple mp3 using one loading bar??

  1. #1
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930

    Problem loading multiple mp3 using one loading bar??

    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");
    	}
    };
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  2. #2
    Junior Member
    Join Date
    May 2009
    Posts
    2
    Hey, I am trying to figure out how to do this too. Did you get an answer? Looking at your code I was wondering about this part:

    var my_audio:Sound = new Sound();
    my_audio.loadSound("audio/"+my_array[k]+".mp3",false);

    if this keeps gettin called over and over, won't my_audio just be the last sound in your array?

    My code does not work either but part of it looks like this:

    var SoundSet:Array;
    function loadSoundSet(mLabel,mov_num){
    SoundSet = new Array();

    var i;
    for(i=0; i<10;i++){
    path = "thePathToMyMP3Set/theFileSeriesPrefix"+i+".mp3";
    varholder.SoundSet[i] = new Sound(varholder);
    var url:String = path;
    varholder.SoundSet[i].loadSound(url, true);
    }
    }

  3. #3
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930
    I haven't figured this out yet...I basically just set up several frames in a row and loaded each sound one at a time...not ideal, but it worked.

    I was calling the loadSound in the loop just to start the loading for the current sound, not to play them. I played the loaded sound I wanted on the appropriate frame within the movie.

    I've got several other projects coming up like this, but will probably do them in AS3, so I'll figure it out for that...
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  4. #4
    Junior Member
    Join Date
    May 2009
    Posts
    2

    Maybe this will help

    Wow, fast reply. Actually just got it working in my application. This is what I did. Hope it helps:

    //declare an array to hold the sounds
    varholder.BFSoundSet = new Array();

    /*this function is called when I want to load a set of sounds (I am loading sets of about 20 short mp3's) stored in diferent files*/

    function loadSoundSet(mLabel,mov_num){
    var i;
    for(i=1; i<11;i++){
    path = mLabel+"/src/"+mLabel+mov_num+"/bf"+i+".mp3";
    varholder.BFSoundSet[i] = new Sound(varholder);
    var url:String = path;
    varholder.BFSoundSet[i].loadSound(url, false);
    }

    function playIt(mySound){
    varholder.BFSoundSet[mySound].start();
    }

  5. #5
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,930
    Excellent!! I'll give that a shot!

    Thanks!!
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center