Multiple Preloaders for external files

I have designed this site with few external swf. I was wondering how can I preload all the externals swf’s file in the same preloader of my first frame and scene. I have this code :
onClipEvent (load)
{
total = _root.getBytesTotal();
}
onClipEvent (enterFrame)
{
loaded = _root.getBytesLoaded();
percent = int(loaded / total * 100);
text = percent + “%”;
gotoAndStop(percent);
if (loaded == total)
{
_root.gotoAndPlay(2);
} // end if
}

and I wanna have the name of the swf that is been loaded showing up on the text box with the bar of progress moving especifically for the progress of that external.

Thanks guys…

I was in a similar boat and this is what I discovered. The code code probablely be tweaked to more fit your specific situation.

OK I figured it out here’s what I got:
////// I just added two files for filesize. you could probably add many types and files.
_root.preloader_mc.onEnterFrame = function() {
filesize = _root.sound_pl.getBytesTotal()+_root.grid_pl.getBytesTotal();
loaded = _root.sound_pl.getBytesLoaded()+_root.grid_pl.getBytesTotal();
preloader_mc._visible = true;
if (loaded != filesize) {
preloader_mc._xscale = 100*loaded/filesize;
grid_pl._visible = false;
sound_pl._visible = false;
} else {
preloader_mc._visible = false;
grid_pl._visible = true;
sound_pl._visible = true;

	if (_root.sound_pl._alpha<100) {
		_root.sound_pl._alpha += 10;
	}
}

};

I hope that helps.

Hello guys,
you can go on dev.webbymx.net
register (free) go in the ressource section and dld the preloader component.
Really easy to use, here is an example:


// create a tmp array to hold your objects
var toLoad:Array = new Array();

// create your object holding the file information
var file01:Object = new Object();
file01.name = "game_var";
file01.type = "XML";
file01.text = "XML";
file01.path = "game.xml";
file01.callback = parseXmlGame;
file01.scope = this;


var file02:Object = new Object();
file02.name = "mc_shared";
file02.type = "MovieClip";
file02.depth = 0;
file02.path = "sounds.swf";
file02.text = "Sounds";

var file03:Object = new Object();
file03.name = "mc_game";
file03.type = "MovieClip";
file03.depth = 1;
file03.path = "rugby.swf";
file03.text = "Game";

// push the object into the array
toLoad.push(file01);
toLoad.push(file02);
toLoad.push(file03);

// once all the file are loaded go to the next scene, label menu
mc_preloader.loaded = function () {
	mc_game._visible = true;
	mc_game.gotoAndStop("menu");

}

// set up the file to dld
mc_preloader.files = toLoad;
// start the dld process
mc_preloader.download();

/* this is a call back function
you can 1 callback per object
there is the objectLoaded callback function as well which is execute each 
time an object is loade
Means that you can do general stuff on your object + particular one with the callback function you've defined*/
function parseXmlGame() { _root.game_var.parseXML(_root.game_var); }

Anyway check the hellp on the website.
Cheers mates :slight_smile:

hey here is the file…
for some reason is not working…

???
Where is the file???

Hey… the file was too big…

Here it is…

Thanks

Hi mate…
Did you tried the way I told you, with the preloader component.
You need to dld it and install it with ExtensionManager (automatic when double clicking on the .mxp)
With the code I gave you above and the help you could do what you want.
If you still have trouble then I could try to help you…

Cheers :slight_smile:

var k = 0;
swfs = new Array("home.swf", "about.swf", "gallery.swf", " video.swf", "contact.swf");
function preloadSwf() {
	var con = container.duplicateMovieClip("con"+k, 9984+k);
	con.loadMovie(swfs[k]);
	var temp = this.createEmptyMovieClip("temp"+k, 99+k);
	temp.onEnterFrame = function() {
		info.text = "Loading "+swfs[k];
		if (con._width) {
			con._visible = 0;
			nextSwf();
			delete this.onEnterFrame;
		}
	};
}
function nextSwf() {
	if (k<swfs.length-1) {
		k++;
		preloadSwf();
	} else {
		con0._visible = 1;
	}
}

scotty(-:

Oh things you should know (if you didn’t read the help) is that every movieclip loaded will have their _visible property set to false.
You can set it to true:
in the callback function
in the objectLoaded function (but here everynovieclip will be visible then)
in the onloaded function accessing the movieclip you wanna show)

Cheers

This is a sample as asked by PM.
You need to put 2 swf to load called toLoad and toLoad2 in the same folder as the preloader.swf cause I didn’t attached them. Or change the name in the fla to whatever you want.

Cheers

Scotty…
I liked this code… realy clean…but could explain this for me…

I have to create a MV called container? right? and I have to putt this code in the first frame right?? and I have to create a dynamic text box called text??
Man… I know I suck in with the AS but I will get there…
Thanks

Yep, put the code in the first frame and have an empty mc with the instance name ‘container’ on stage (positioned where you want to have the topleft of your pictures). For the text have a dynamic textfield with the instance name ‘info’

scotty(-: