dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: sound progress bar

  1. #1
    Junior Member
    Join Date
    Dec 2002
    Posts
    14

    sound progress bar

    I have built an XML driven MP3 player that runs fine when MP3's are NOT streaming. My problem is when I set it to stream (loadMovie to "true") my progress bar does not reset when a new sound loads. In otherwords mySound.position doesn't return to 0.

    Here's the code:

    Code:
    function preloader() {
    	// load sound
    	mySound = new Sound(this);
    	mySound.loadSound(audioPath+firstSound, true);
    	trace(audioPath+firstSound);
    	if (listPosition == 1) {
    		songMenu();
    	}
    	// loadbar
    	loadBar._xscale = 0;
    	this.createEmptyMovieClip("tempLoader", this);
    	tempLoader.onEnterFrame = function() {
    		if ((_root.mySound.position/1000)>1) {
    			progressBar();
    		}
    		var bt = mySound.getBytesTotal();
    		var bl = mySound.getBytesLoaded();
    		var calcul = Math.floor(bl*100/bt);
    		songInfo.musicInfo.text = "";
    		if (calcul == 100) {
    			this.removeMovieClip();
    			_root.songLoaded = 1;
    			loadBar._xscale = 100;
    			_root.percentage = "";
    			//mySound.start();
    			//mySound.isPlaying = true;
    			textInfo();
    		} else {
    			percentage = "Loading "+(isNaN(calcul) ? 0 : calcul)+"%";
    			loadBar._xscale = calcul;
    		}
    	};
    }
    //
    //// progressbar
    progressBar = function () {
    	this.createEmptyMovieClip("progLoader", 850);
    	progLoader.onEnterFrame = function() {
    		text = (_root.mySound.position);
    		progressBar._xscale = Math.round((_root.mySound.position/_root.mySound.duration)*100);
    		mySound.onSoundComplete = function() {
    			songNumber++;
    			if (songNumber<audioLen) {
    				trace("length="+audioLen);
    				trace("songnumber="+songNumber);
    				this.removeMovieClip();
    				firstSound = djXML.firstChild.childNodes[songNumber].attributes.title;
    				// trace(firstSound);
    				progressBar._xscale = 0;
    				preloader();
    			} else {
    				trace("last");
    				this.removeMovieClip();
    				songNumber = 0;
    				firstSound = djXML.firstChild.childNodes[songNumber].attributes.title;
    				trace(firstSound);
    				progressBar._xscale = 0;
    				preloader();
    			}
    		};
    	};
    };
    Help please.

  2. #2
    Junior Member
    Join Date
    Dec 2002
    Posts
    14
    bump*

  3. #3
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Can't you attach your .fla, rather than asking me to create one out of a truncated script?

    If it's too heavy, upload it to your site, and provide a link here to download it from there. Then maybe you'd get better help!

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