I’ve having a problem with the onload even handler. What is a better way to detect when a mp3 has loaded? Right now the script works fine for preloading, but if the mp3 has already been cached with IE, the onload function isn’t called. It’s weird because it works fine on firefox and both browsers are using the same version of flash.
I’m really new to Flash and AS, my first thought would be to compare the total size of the clip to the loaded size of the clip to call the getURL function. I still don’t quite understand how to get the updated values for those variables outside of the onEnterFrame function. So far what I’ve tried either calls getURL forever or never calls it because the loaded var is stuck at 0.
If someone could point me in the right direction, I’d really appreciate it.
//song for previewing only
if(!song_url) song_url = "flash.mp3";
var percent;
if(!_root.percent) _root.percent = 0;
//loads sound from song_url
_root.mySound = new Sound();
_root.mySound.loadSound(song_url,false);
this.onLoad = function () {
_root.loadBar._xscale=mySoundBar;
_root.percent=mySoundBar;
}
this.onEnterFrame = function () {
mySoundBytesTotal = _root.mySound.getBytesTotal();
mySoundBytesLoaded = _root.mySound.getBytesLoaded();
if (mySoundBytesLoaded>0) {
mySoundBar=Math.round((mySoundBytesLoaded/mySoundBytesTotal)*100);
_root.loadBar._xscale=mySoundBar;
_root.percent=mySoundBar;
}
}
//I had tried to use if(percent == 100) { getURL() }, but I can't get percent to update
trace("completed: "+ percent);
_root.mySound.onLoad = function() {
getURL("lesson.php?a=view");
}