Yet Another Preloader Question Also Remoting Question

Hi Everyone,

I feel like a complete idiot here, but I am a horrible programmer.

I have an application that is going to be doing some Flash Remoting.
It also has some big Bitmaps in it. The filesize is huge.

I made another swf to work as an external preloader.
I used the new components (progess Bar, and Loader), and I know they are big too, but as I said in a seperate file the calls my main app.

THe Remoting question is this: I have read on a forum somewhere that there may be an issue with the remoting and the fact that it is loaded into another swf. Has anyone found this to be the case?

I’m wondering if I should rebuild the preloader in frame one of my main swf?

The stupis preloader question is: as it is, because it is built with the components, when it loads the Main.swf into the loader MC, the progressbarMC stays in front. I have tried several ways to get it to removeMovieClip (the progress bar), but have been confounded on all fronts…Can someone please fill me in on the best way to do that, and if you can, the remoting question too!

Thanks a lot, sorry to be so long winded.

Here’s your best bet:

Build a load bar design of ANY width / height. Then place it on the stage in the first frame of your movie that you want to load, name it “loadBarMC” and add this code to the first frame of the movie (do NOT add this code to the loadBarMC itself…it’d be ideal in its own layer, an “Actions” layer):

// initialize the loadbar
_root.loadBarMC.onEnterFrame = function() {
	// stop the playhead
	_root.stop();
	// declare some variables
	var loaded = _root.getBytesLoaded();
	var total = _root.getBytesTotal();
	var totalPercent = Math.round((loaded/total)*100);
	// make the width of the loadbar
	// equal to the percent loaded
	_root.loadBarMC.loadBar_bar._xscale = totalPercent;
	// echo variables to output window
	trace("loaded = "+loaded);
	trace("total = "+total);
	trace("loadBar width = "+totalPercent);
	// if the movie is loaded, get the
	// playhead going again
	if (loaded == total) {
		_root.loadBarMC.gotoAndPlay("loaded");
		_root.gotoAndPlay(2);
		trace("Loaded!");
		// clear the onEnterFrame event
		// so that it's not still running
		// when it doesn't need to be
		delete this.onEnterFrame;
	}
};

It’s the best way to preload for a few reasons:
1) Because it’s in an onEnterFrame, it’s updated very quickly (appearing smoother).
2) It’s all done in ONE frame, with ONE movie clip.
3) Never fails.
4) It doesn’t require your loadBar to be 100px, any width works.

You can add a border around your loadBarMC so that it appears to fill the border as it loads.

I could post an FLA if you’d like, or if you’re having any troubles with the above code I’d be more than willing to do what I can to help. :geek:

hi newhopekenny,
I tried the code you gave but wasn’t sure if i’m doing it right can i see your fla. or can you look at mine. Thanks in advance.

P.S so the preloaders in the tutorials uses up a lot of file size than the one you did.

I’m using 2004, and it didn’t seem to work…if you could post an .fla, that’d be great…

Had to move the _root.stop() outside of the function to make it work (still not sure why). As soon as I figure out why, I’m going to build a drop-in loader component based on this one.

That way I’ll have something to drop in the first frame to load the entire movie and not have to waste time writing loader scripts.

Here ya go:

Thanks NewHope,

I’ll give this a shot. I’ll let you know how it works out.