Best way to do a preloader?

I typed up a preloader to work, but being a coder in another language other than AS, i like to have clean code…

this is my preloader that works:

onClipEvent (enterFrame) {
total = _root.getBytesTotal();
loaded = _root.getBytesLoaded();
percent = int(loaded/total*100);
gotoAndStop(percent);
if (loaded == total) {
_root.gotoAndStop(2);
}
}

where i just put that on the movie clip and have an extra frame with stop ();


is there a more pro way with code to do this? i saw kirupa’s tut, but there are other ways… Just looking for the best way to do a preloader in the latest way out…

From the Kirupa “Creating a preloader in one frame” tutorial.

if (_framesloaded>=_totalframes) {
	gotoAndPlay (2);
} else {
	gotoAndPlay (1);
}

Dont know if it’s considered more pro or not, (cause Im not) But I cant say Ive seen it any cleaner or simpler than that.