Preloader Problems... for the umpteenth time

I just can’t seem to get preloaders right in flash. I wish there was a one-size-fits-all-preloader-solution… for instance when you need to play an animation while a movie is loading. Sounds simple but I guess I’m stupid.

Anyway, I have a movieclip which in and of itself has an animation, from frames 1 to 100. I then put this code on the movieclip itself:

onClipEvent(enterFrame) {
loadedbytes=getBytesLoaded();
totalbytes=getBytesTotal();
percentloaded = int(loadedbytes/(totalbytes/100));
if (loadedbytes == totalbytes) {
nextScene();
}
else {
loader_mc.gotoAndStop(percentloaded);
}
}

So why does it not work and decide to look like its going to give you a seizure? (it just keeps flickering really fast and shows both the loader movieclip and the content of the next scene…) the movieclip doesnt ever go through the animation.