My Preloader works fine, loads the mp3 not a problem displays the percentage without a problem…so what is my problem you ask? Its the fact that as soon as the mp3 is loaded to 100% and is meant to play the rest of my animation with mp3 playing in the background, it for whatever reason plays my movie up to the 20th frame, and goes back to the 1st frame and continously loops… I have no actionscript to tell it to do this…and frankly I have been working at fixing this for the last 3 days and feel I have exhausted every avenue.
I originally have all of the script attached to an empty Movieclip myMusicMC, but for some reason the preloader would not work, so I seperated the code I originally had, some on the empty movie clip, the rest on to the main stage, and it worked, but now there is this new problem.
Here is my code on the empty MC.
onClipEvent(load) {
//Set the Preloader Bar to 0.
_root.loadBar._xscale=0;
}
//
onClipEvent(enterFrame) {
_root.mySoundBytesTotal = _root.myMusic.getBytesTotal();
_root.mySoundBytesLoaded= _root.myMusic.getBytesLoaded();
_root.mySoundLoading=Math.round((_root.mySoundBytesLoaded/_root.mySoundBytesTotal)*100);
// Update text box with percent loaded
if (_root.mySoundLoading!=null) {
_root.percentLoadedText=_root.mySoundLoading+"%";
}
// Scales load bar
_root.loadBar._xscale=_root.mySoundLoading;
}
Here is the code on the main stage.
stop();
_root.myMusic = new Sound();
_root.myMusic.loadSound("music.mp3", false);
//define a function to preload the sound
function checkLoad() {
var percentLoaded = (_root.myMusic.getBytesLoaded()/_root.myMusic.getBytesTotal())*100;
progress = Math.round(percentLoaded);
if (percentLoaded == 100) {
_root.gotoAndPlay(3);
}
}
//create a setInterval to call the preload function until the sound has loaded
checkProgress = setInterval(checkLoad, 1000);
The idea was to have the mp3 completely loaded into cache, and then starting right away when the animation would begin, with fade in etc. I have seen this done so I know there is a way, and it feels like I am so close I just need your guidance to fix it.
Thanks for your help.