Need help with Loading Setup


#1

Okay, I have a little dilemma. I have built myself a site entirely in flash, which contains 3 scenes. A preloader scene, A intro and the actual site. How do you pros usually setup the preloader. I have it all coded but the problem is when i upload my site, you download 1 big .swf file instead of starting the preloader and having it load the site. So i go to my site, it takes a while to load and then you see 400k/400k loaded on the preloader part. Should i make each of the 3 scenes into a seperate .swf file and then use the load movie command? I use the getbytesloaded command and i dont know how to get the amount loaded from a different movie on from the scene.

Here is the simple code for the preloader.
onClipEvent (load) {

textPre = " ";

}
onClipEvent (enterframe) {
textPre = _root.getBytesLoaded() /1000 + “Kb” + “/” + _root.getBytesTotal() /1000 + “Kb”;
if (_root.getBytesTotal() == _root.getBytesLoaded() ) {
textPre = math.floor(_root.getBytesLoaded() /1000) + "Kb / " + math.floor(_root.getBytesTotal() /1000) + “Kb”;
}
}

Any suggestions on a work around…
(this is my first site ever so… im a newb)

Thx in advance for the replies.


#2

i generally have separate swf’s load for each section, that way the initial site loads pretty quickly (even if you’re a dial-up user).

chris


#3

I agree. Whenever possible, loadMovies separately as they are called by the user. That way, if the user never goes to a particular section, they never have to download it. Then put a preloader on each movie that is to be loaded. The user gets to ground zero quickly, and since every section is in its own movie, then each small load is more bearable.

The down side to this approach is when each section has long load times. Nobody wants to click…wait for load…see sections…choose section…wait for load…see subsection…choose subsection…wait for load…see samples…choose sample…wait for load… I think you get the picture. Save significant loads for the real content/animations, etc.

Good luck…can’t wait to see your site.

Dain


#4

Thx for the relpies,
How do i set it up so it preloads the intro movie while the preloader movie is playing? Is there a way i can start loading the intro movie and check to see the amount of bytes loaded from the intro, while the preloader is there? When i seperated the scenes into individual movies the command i used _root.getbytesloaded () only checks the bytes loaded in the preloader , but i want to check the bytes loaded in another .swf file. I hope you can follow my troubles, and i hope someone can help me. Thx a bunch :thumbsup:


#5

Okay, so if I understand you correctly, what you want to do is:

Have your intro play while your main movie is loading. (you may want to preload your intro, have it play, then preload the movie as it’s playing–double up your preloaders).

Anyway, have a separate preloader on the movie that is loading. Actually put the preloader code on the actual loading movie, not the main movie. Then, when the preload on the loading movie is satisfied, tell your main movie’s timeline to move on.

In order to talk to movie clips within a movie, you have the right idea, you simply follow it’s path to its instance name, however, when you load a movie, since it has its own independent timeline and is not considered a part of the original move (it’s just renting space), you have to talk to the loaded movie’s level. The main movie is always level 0 (zero). So when you load a movie into, let’s say, level 10, you will talk to it like this: _level10.gotoAndPlay (“main”);

or to talk from the loaded move to the main movie,
_level0.nextScene();

or whatever.

I hope that answers your question or points you in the right direction. If I totally missed the point I apologize.

Good Luck,
Dain


#6

ok, i wrote this for a content engine i use…its been edited down a bit so apologies if ive missed something or its not clear


loader = function () {
	//show some text if required
	_root.loadElement = "loading... "+loadAssets[loadStack].note;
	// if we are not in the process of preloading the root movie, then we need to send a loadMovie trigger
	if (loadStack != 0 ) {
		// and if we have not already sent a comment to load the movie, we need to send one
		if (!sent) {
			// depending on the use of the preloader, we either need to load into the correct level for that engine element
			loadMovieNum($assets+loadAssets[loadStack].page, loadAssets[loadStack].level);
			// this will stop the same preloading loop from sending more than one loadMovie command
			sent = true;
		}
	}
	prePath = _root["_level"+loadAssets[loadStack].level];
	// we are expecting to get a couple of undefined results before flash has been able to  load the header information
	if (prePath != undefined) {
		// if the file is loaded
		if (((prePath.getBytesLoaded()/prePath.getBytesTotal())*100)>98) {
			// clear the current setInterval
			clearInterval(_root["loaderHandle"+loadStack]);
			// as the handler is kept as a variable, delete it for cleaning up purposes
			delete _root["loaderHandle"+loadStack];
			// increase the variable that is used to reference where we are in the loading stack, which references the loadAssets array
			loadStack++;
			// if we have not finished loading the stack
			if (loadStack<loadAssets.length) {
				// send a new loadMovie command
				sent = false;
				// fire off a new setInterval
				loadFunction(true);
				// otherwise we are done loading, so continue
			} else {
				postContentLoadFunction();
				// tidy up
				delete loadStack;
				delete per;
				delete prepath;
				delete sent;
				delete loadAssets;
			}
		} else {
			// get % loaded
			per = (prePath.getBytesLoaded()/prePath.getBytesTotal())*100;
			preloading.cover._xscale = Math.round(per);
			if (!init) {
				_root["_level"+$contentLevel].stop();
			}
		}
	}
};
//set interval is triggered by the onLoad of the rootXML the first time round, and is the subsequently called by the load function it creates
//until all levels defined in the loadAssets array have been loaded
loadFunction = function () {
	_root["loaderHandle"+loadStack] = setInterval(loader, 100);
};


$backInterfaceLevel = 1;
$contentLevel = 2;	
$lowerInterfaceLevel = 3;
$interfaceLevel = 4;
$dynNavLevel = 5;
$reportLevel = 6;
$coverLevel = 7;

loadAssets = [
	{page : "root", level : 0, note : "core"}, 
	{page : "wm00.swf", level : $coverLevel, note : "core"},
	{page : "lm00.swf", level : $backInterfaceLevel, note : "interface"}, 
	{page : "i01.swf", level : $interfaceLevel, note : "interface"}, 
	{page : "nav00.swf", level : $dynNavLevel, note : "navigation"}, 
	{page : "rep00.swf", level : $reportLevel, note : "reporting"}
	];



#7

when triggered that will go through an array of assets to load (it could just be 1 or at the start as with my engine is about 7)

to call it :

just define a loadAssets array with the same structure as the one shown and then call

loadAssets();


#8

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.