Thanks again for your reply John.
This creates a problem because users will be visiting a webpage, and the mp3 must load correctly.
The successful loading of the mp3 is crucial to the success of the website.
I am not using the onLoad function - but unstead I am testing the bytes loaded.
This solves the caching issue.
Here is the new problem (incredibly strange):
Sometimes, not all the time but only sometimes when I load the page (with my cache cleared) Flash thinks that the bytes loaded is equal to the total bytes.
Try it out - if it says "Playing" and if the time is "0:00 | 0:00" then the file isnt really loaded. But you'll see that the KB loaded displays as being equal to the total. its so weird. you can trigger this strange result by click refresh a bunch of times while the file is loading.
The consequence is that the 'play' function fires, which means that is won't fire when the file actually loads. Another consequence is that the user has no idea that the file is loading, because flash thinks its done.
See it at
www.amrstudios.com/temp/mp3player I did not post all my code - just what is relevant.
this.onEnterFrame = function() {
if (!_global.isLoaded) {
disableButtons();
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) && (total1>4) && (loaded1 == total1) && (!_global.isStarted)) {
enableButtons();
playSound();
ppbutton.gotoAndStop("play");
_global.isLoaded = true;
}
} else {
myMusic.loadSound(_global.sourceFile, false);
}
} else {
_global.dur = myMusic.duration;
_global.pos = myMusic.position;
this.totalTime = _global.dur/1000;
this.elapsedTime = _global.pos/1000;
}
showTime(this.totalTime, this.elapsedTime);
};