Preloading External .swfs

I’m looking for a peice of actionscript which will give me a load-bar preloader for an externally loaded .swf file. I’m not great with actionscript (though not totally out of it.) and am currently using the :

if (_framesloaded>=_totalframes) {
} else {

approach, which doesn’t give me a loadbar. When I tried to use the loadbar like this:

bytes_loaded = Math.round(_root.getBytesLoaded());
bytes_total = Math.round(_root.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
_root.loadBar._width = getPercent100;
_root.loadText = Math.round(getPercent
if (bytes_loaded == bytes_total) {

(and with a “gotoAndPlay(1);” in the next frame)

it failed to work for both the regular movies within MX 2004 as well as the externally loaded ones. I know there’s an easy fix here…I just don’t know what it is.

Where did you place your code? If your loading your external SWF into a movieclip the code should go on the movieclip itself. Here’s an example of an easy preloader I’ve done before:

	total = _parent.getBytesTotal();

	current = _parent.getBytesLoaded();
	percent = Math.floor((current/total)*100);
	_xscale = percent;
	_parent.loadPercent = percent+"%";

	if (percent >= 100){
		_xscale = 100;