Pre-Loaders and Empty Movie Clips

I am trying to load contact.swf into an empty movie clip found within a file called main.swf . The instance name of the empty movie clip is"play".

At the start of my .swf that I am attempting to have a progress bar that indicates the percentage loaded. I’ve inserted five frames at the beginning of the contact.swf and the following details the scripting found on each frame:

2)loadpercent = “0%”;
loadBytes = “0%” + Math.round((_root.play.getBytesTotal() /1024) * 1000) /1000 + “Kb”;

3)if (_root.play.getBytesLoaded() == _root.play.getBytesTotal()) {
loadPercent = “100%”;
loadBytes = (Math.round((_root.play.getBytesLoaded() / 1024) * 1000) /1000 + “Kb of” + Math.round((_root.play.getBytesTotal() / 1024) * 1000) /1000 + “Kb total Loaded.”);
gotoAndPlay(“start”);
}

4)gotoAndPlay (2);

5)stop ();

Then there is a movie clip within contact.swf named
mc-LoadBarFill which contains a grey bar located to the right of the centre point. Here is the scripting found in the frames:

  1. this._xscale = ((_root.play.getBytesLoaded() / _root.play.getBytesTotal()) * 100);

  2. gotoAndPlay (1);

When I load the main.swf and click on the link to contact.swf, the pre-loader doesn’t work. Is there something wrong with my scripting?

thanks…

what up mattty79,
so i had the same question, and it took a while for me to get it, but i just solved it actually…so here we go. There’s a great tute on the kirupa site for a preloader, and you just have to tweak it a bit to get it to work for loaded swfs.
here’s the code i got from kirupa and then fit to my site for loaded swfs. IMPORTANT::: the code must be placed on all of the movies you are loading, so in your case CODE IN CONTACT.SWF

bytesLoaded = Math.round(_parent.contentsa.getBytesLoaded());
bytesTotal = Math.round(_parent.contentsa.getBytesTotal());
getPercent = bytesLoaded/bytesTotal;
_parent.contentsa.progressBar._width = getPercent200;
_parent.contentsa.loadT = Math.round(getPercent
100)+"%";
if (bytesLoaded == bytesTotal) {
_parent.contentsa.gotoAndStop(3);
}

now where i have contentsa you will “play”. Moreover, the progress bar for me is “progressBar” and the the percentage loaded in numbers is “loadT”
so you place the above code on frame 1
on frame 2 you place the code
_parent.contentsa.gotoAndPlay(3)
//again you will have play where i have contentsa

then in the third frame you start your movie…
hope that helped

cheers
P-cell

thanks for your help P-Cell!!

I thought no one would reply!!! Just a quick question though, how does _parent work and _root not?

peace

I am having the same problem…and I think I understand this code, but the one thing I dont understand is the “play” or “contentsa” instance name. Is that the instance name of the empty movie clip? For example the instance name that is loaded for my movie clip is “contents”, but for some reason if I use that instance name in the code my preloader bar doesnt work. It still preloads the content but the bar does not function. It just stays at full size and shows nothing for the percentage.

Can anyone help?