External SWF Preloader Problem

[font=Comic Sans MS]Hey people, this is the first time i’m post on the forum, so i’m not too sure if i put this post in the catorgory, but anyway.[/font]

[font=Comic Sans MS]I’ve been using flash for approximatly 6 months, still very useless at it, however i know my way around the majority of the program and know how to use the help panel ;o)[/font]

[font=Comic Sans MS]Right, so i’ve built most of my site and then i tested it. All went well until i got a friend to test it him being on 56k didn’t help the sitituation as he saw a blank screen most of the time (slow loading). So i decided to put preloaders into the site, putting one onto the main swf was no problem, simple as A-B-C. But i’ve got buttons that are in swf format and so are loaded externally into the main swf as MCs, problem is that these buttons come up as about 10k each and theres about 14 of these. So it takes time for them to load is well, making it look as if half the site is missing while they load. Tested in Flash using the download simulator.[/font]

[font=Comic Sans MS]Now what i want to do is create a preloader that will load each of the buttons in one go, as one MCs which sounds way out of my league to me, so if thats not possible then i wouldn’t mind it being done automatically one by one, but where each MC would be there would have to be a small pre-loading bar (percentage) which disappears after the MC is loaded. [/font]
[font=Comic Sans MS]I’ve spent almost 36 hours (literally) researching various possibilties and various different pre-loaders, but none of them seem to want to do what i need :o([/font]
[font=Comic Sans MS]I’ve included an image of what I’m trying to achive, as i’m sure you will probably need to refer to it (i’ve never been too good at explaining stuff)[/font]
[font=Comic Sans MS]Massive thanks in advance, this is possibly my last resort, seen as i don’t know many people good with flash.[/font]
[font=Comic Sans MS][/font]
[font=Comic Sans MS]-- I think this should have gone into the activescript group now :blush: --[/font]

Ok if im getting this right, you want a preloader that loads all external SWF files then goes to the main SWF right?

If that is the case, here is one way to do it…

MAIN SWF:
2 frames, first frame will hold the external SWF files and a preloader.
All external SWF files should be loaded into movieclips.
The preloader should be made as a movieclip that get’s activated in frame1.
Make sure the external SWF movieclips are both in frame1 and frame2.
In frame1 load all your external SWF files, then stop the timeline.
Make sure your preloade movieclip is on a layer higher than the SWF movieclips.
In your preloader movieclip, you make a loop that checks for either total frames
loaded or total bytes loaded, that way you know when they all have been
loaded. Use getBytesLoaded & getBytesTotal.
When they all have been loaded your preloader should tell the main SWF to enter frame2, thereby going pass the preloader and your movie clips should be there…

Hope this helps, hell hope you understand what I’m saying atleast :)…

Could i use the following code as the preloader?

 
function preload(MyCache) {
 if (!MyCache.doneLoading) {
  if (MyCache._framesloaded>0 && MyCache._framesloaded == MyCache._totalframes) {
   MyCache.doneLoading = true;
  }
  OutputLoaded = Math.round((MyCache.getBytesLoaded()/1024));
  OutputTotal = Math.round((MyCache.getBytesTotal()/1024));
  var percentLoaded = (MyCache.getBytesLoaded()/MyCache.getBytesTotal());
  Bar._width = BarBorder._width*percentLoaded;
  percentage = Math.round((MyCache.getBytesLoaded()/MyCache.getBytesTotal())*100)+"%";
 }
}

each external file has to be added… Remember to name each movie clip that holds an external SWF file…

_root.getBytesTotal & _root.getBytesLoaded (main swf)
_root.button1.getBytesTotal & _root.button1.getBytesLoaded
_root.button2.getBytesTotal & _root.button1.getBytesLoaded
etc…

loadedbytes = Math.ceil(_root.getBytesLoaded + _root.button1.getBytesLoaded + _root.button2.getBytesLoaded);
totalbytes = Math.ceil(_root.getBytesTotal + _root.button1.getBytesTotal + _root.button2.getBytesTotal);
if (loadedbytes == totalbytes) {
_root.gotoAndPlay(2);
}

This basicly checks and makes sure each external SWF is loaded completely, when they are then jumping to frame 2 on the main SWF…

NOW there is one problem with this, since you have so many small files, it will happen that since you load the external swf one by one, that the check is done on the first swf and it’s downloaded, which leads to the problem, since then the check will be true and the timeline will change even though not all the swf are loaded… There you need to make sure all swf files are loaded.

if (loadedbytes == totalbytes) {
//put in a check that checks each file and see if it’s downloaded
_root.gotoAndPlay(2);
}

Kinda double work, but I really don’t see a better way, in better I mean less code…

I’m a little lost now, where would i put the links to the external swf files?

I’ve included what i assume you meant for me to do (all the little buttons are also included).

well not really…

You have to create a moveclip as preloader, it’s in there you do all this…

main swf (preloader & main site)
external swf
external swf

in the preloader you build how you want it to look… like the pic you had in your first post…
You need to track each external swf by itself in order to display progress for each and everyone.
Then you can just total it, whats loaded and what is total, when that is equal then you know all the external swf files have been loaded and you can move the timeline on main stage.

Main stage is infact only 2 frames, one for the preloader and one for the display of external swf’s…

It took me a long time getting my preloader to work the way I wanted it to, and you want the same thing… It’s alot of coding, since I double check values and make sure the progress is correct…

Build you main swf first… 2 frames… top layer add you preloader as a movieclip.
When you got that done, add soem more layers below the preloader so the preloader will cover those layers. In those layers you add movieclips which you will use to load the external swf into. Remember to give them a INSTANCE NAME so we can refer to them later.
Make sure the preloader only is placed in frame 1, but your movieclips have to be in both frame 1 & 2.
Try get that done first.