I am working on tryinng to load mp3’s dynamically. I am using code from Billy T below for laoding the file. Works great for the load. But then I tried to start the loaded mp3 . It plays fine on my pc locally, but not if I put it on a server and then try it. To get it to work, you must refresh your browser - i.e. it only plays on the second load (or sometimes third). This is driving me pretty crazy - why would this be?
Here is the link to the swf on the server - you will see that a refresh is needed to get the music to play:
http://www.efuturevision.com/juke/test3.html
Here is the entire fla that is playing on the server:
mSound = new Sound();
mSound.loadSound("coolloop.mp3");
sndFrameFunc();
//test load sound
myMusicPosition = 0;
mSound.start(myMusicPosition, 0);
function sndFrameFunc() {
if (!this.fullyLoaded) {
this.onEnterFrame = function() {
var t = mSound.getBytesTotal();
totalbytes.text = t;
var l = mSound.getBytesLoaded();
bytesloaded.text = l;
var pc = l/t;
percentdone.text = pc*100+"%";
this.loadBar2._width = pc*100;
if (t && l == t) {
this.fullyLoaded = true;
delete this.onEnterFrame;
result.text = "Deleting onEnterFrame within if block...";
}
};
}
}