Hi. The following code is used for an MP3 player.
I did not include the declaration of various variables nor did I include the functions for the buttons; I am mainly concerning with the loading prodecure.
My Player works very well (loading included) - but once in a while it fails to load the mp3 from the server and a hard refresh is required. I thought maybe someone here might feel like helping me out by checking over my code. Thanks.
__________________________
myMusic = new Sound(myMusicMC);
myMusic.loadSound(sourceFile, false);
disableButtons();
this.onEnterFrame = function() {
if (!_global.loaded0) {
loaded1 = myMusic.getBytesLoaded()/1024;
total1 = myMusic.getBytesTotal()/1024;
if (loaded1 != undefined) {
perc = int((loaded1*100)/total1);
progressBar.bufferPosition._xscale = perc;
status.text = "Loading: ";
status.text += perc;
status.text += "%";
if (loaded1>4 && loaded1 == total1) {
if (!_global.started) {
slideFX.play();
enableButtons();
playSound();
ppbutton.gotoAndStop("play"
;
}
_global.loaded0 = true;
}
}
} else if (_global.isPlaying) {
_global.dur = myMusic.duration;
_global.pos = myMusic.position;
this.totalTime = _global.dur/1000;
this.elapsedTime = _global.pos/1000;
if (_global.dur == _global.pos) {
stopSound();
}
}
showTime(this.totalTime, this.elapsedTime);
};
//
stop();
I did not include the declaration of various variables nor did I include the functions for the buttons; I am mainly concerning with the loading prodecure.
My Player works very well (loading included) - but once in a while it fails to load the mp3 from the server and a hard refresh is required. I thought maybe someone here might feel like helping me out by checking over my code. Thanks.
__________________________
myMusic = new Sound(myMusicMC);
myMusic.loadSound(sourceFile, false);
disableButtons();
this.onEnterFrame = function() {
if (!_global.loaded0) {
loaded1 = myMusic.getBytesLoaded()/1024;
total1 = myMusic.getBytesTotal()/1024;
if (loaded1 != undefined) {
perc = int((loaded1*100)/total1);
progressBar.bufferPosition._xscale = perc;
status.text = "Loading: ";
status.text += perc;
status.text += "%";
if (loaded1>4 && loaded1 == total1) {
if (!_global.started) {
slideFX.play();
enableButtons();
playSound();
ppbutton.gotoAndStop("play"
}
_global.loaded0 = true;
}
}
} else if (_global.isPlaying) {
_global.dur = myMusic.duration;
_global.pos = myMusic.position;
this.totalTime = _global.dur/1000;
this.elapsedTime = _global.pos/1000;
if (_global.dur == _global.pos) {
stopSound();
}
}
showTime(this.totalTime, this.elapsedTime);
};
//
stop();