View Full Version : Preloader + multiple swfs
kaziorvb
11-04-2006, 07:50 PM
hi, ive got a problem (with loadin multiple swfs)
my goal is to load to cache (or wherever else) all (5) swfs that ive got on my site.
my site is main swf with few buttons that load external swfs (eg. news.swf) into a scrollpane in main.swf
i wanna load all the swfs before showin main.swf - to make the site runnin smoothly and clearly.
its:
load all swfs -> show main.swf -> be able to instantly show other swfs by clickin right button in main.swf
how to do it?
anonymous
11-04-2006, 08:53 PM
Attach your main movie's fla and post links to your external .swfs.
wvxvw
11-05-2006, 01:17 AM
take a look at MovieClipLoader class, it alouds creating multiple downloads through one instance. Also it has predefined events like .onLoadCompleted(), .onLoadProggres() etc. that might be useful in your case.
anonymous
11-05-2006, 06:32 AM
http://www.actionscript.org/resources/articles/3/1/MovieClipLoaders-Part-1/Page1.
http://www.senocular.com/flash/tutorials/preloading/
kaziorvb
11-09-2006, 06:28 PM
hey finally i made it.
here comes the code of the loader.swf file. it contains few text infos, a bar (movie clip named lada)
var myMCL = new MovieClipLoader();
myMCL.onLoadStart = function (targetMC)
{
var cz1 = myMCL.getProgress("_level0.myMC1");
var cz2 = myMCL.getProgress("_level0.myMC2");
var cz3 = myMCL.getProgress("_level0.myMC3");
var cz4 = myMCL.getProgress("_level0.myMC4");
var cz5 = myMCL.getProgress("_level0.myMC5");
var xloaded = (((cz1.bytesLoaded + cz2.bytesLoaded + cz3.bytesLoaded + cz4.bytesLoaded + cz5.bytesLoaded)*100)/(cz1.bytesTotal + cz2.bytesTotal + cz3.bytesTotal + cz4.bytesTotal + cz5.bytesTotal));
purcent.text = Math.round(xloaded); + "%";
setProperty (lada, _width, (xloaded*4));
}
myMCL.onLoadProgress = function (targetMC, loadedBytes, totalBytes) {
var cz1 = myMCL.getProgress("_level0.myMC1");
var cz2 = myMCL.getProgress("_level0.myMC2");
var cz3 = myMCL.getProgress("_level0.myMC3");
var cz4 = myMCL.getProgress("_level0.myMC4");
var cz5 = myMCL.getProgress("_level0.myMC5");
var xloaded = (((cz1.bytesLoaded + cz2.bytesLoaded + cz3.bytesLoaded + cz4.bytesLoaded + cz5.bytesLoaded)*100)/(cz1.bytesTotal + cz2.bytesTotal + cz3.bytesTotal + cz4.bytesTotal + cz5.bytesTotal));
purcent.text = Math.round(xloaded); + "%";
setProperty (lada, _width, (xloaded*4));
}
myMCL.onLoadComplete = function (targetMC)
{
var cz1 = myMCL.getProgress("_level0.myMC1");
var cz2 = myMCL.getProgress("_level0.myMC2");
var cz3 = myMCL.getProgress("_level0.myMC3");
var cz4 = myMCL.getProgress("_level0.myMC4");
var cz5 = myMCL.getProgress("_level0.myMC5");
var xloaded = (((cz1.bytesLoaded + cz2.bytesLoaded + cz3.bytesLoaded + cz4.bytesLoaded + cz5.bytesLoaded)*100)/(cz1.bytesTotal + cz2.bytesTotal + cz3.bytesTotal + cz4.bytesTotal + cz5.bytesTotal));
purcent.text = Math.round(xloaded); + "%";
setProperty (lada, _width, (xloaded*4));
if (xloaded == 100){
loadMovie("main.swf",_level0);
}
}
myMCL.onLoadInit = function (targetMC)
{
var cz1 = myMCL.getProgress("_level0.myMC1");
var cz2 = myMCL.getProgress("_level0.myMC2");
var cz3 = myMCL.getProgress("_level0.myMC3");
var cz4 = myMCL.getProgress("_level0.myMC4");
var cz5 = myMCL.getProgress("_level0.myMC5");
var xloaded = (((cz1.bytesLoaded + cz2.bytesLoaded + cz3.bytesLoaded + cz4.bytesLoaded + cz5.bytesLoaded)*100)/(cz1.bytesTotal + cz2.bytesTotal + cz3.bytesTotal + cz4.bytesTotal + cz5.bytesTotal));
purcent.text = Math.round(xloaded); + "%";
setProperty (lada, _width, (xloaded*4));
}
myMCL.onLoadError = function (targetMC, errorCode)
{
}
myMCL.loadClip("main.swf","_root.myMC1");
myMCL.loadClip("newsy.swf", "_root.myMC2");
myMCL.loadClip("lekcje.swf", "_root.myMC3");
myMCL.loadClip("info.swf", "_root.myMC4");
myMCL.loadClip("kontakt.swf", "_root.myMC5");
yeah it works. but i want to correct the loading bar cuz its not good. it doesnt load content smoothly (from 0% to 100%), but sometimes it jumps back (eg. from 70% back to 55%). i know the reason... its because of myMCL.loadClip command. all the clips arent being loaded at once. it has to wait some time to start loading next, so the others' bytesTotal are still 0, so the percent isnt being shown correctly...
i tried to fix it by makin another swf containin all the other swfs loaded into it (in Loader components or by usin loadMovie command in the first frame), and make the loader load that swf (its one file so the problem with simultaneous loading multiple files would disappear) - but loader just loaded that file without loading the containin swfs...
how to fix it?
maybe before loading all the swfs in the loader just get size of each one? - it would help... but i dunno how to do it...
or maybe the additional swf that contains all the other swf would be best here? but i want that swf to always contain current newsy.swf, kontakt.swf etc files - without any need to import them into it when one of them has been changed...
hope you understand it - if not - ask - i will answer
anonymous
11-09-2006, 07:31 PM
You then need to pre-preload each file just to the point when you get access to the total bytes of each file, interrupting that pre-preload and moving on to the next file and adding all of each file's total bytes so the global bytes count can be used as 100% mark on your loadbar.
kaziorvb
11-09-2006, 09:29 PM
ok i understand,
but how to get size of each file in actionscript?
i dont wanna change the bytes count each time i will change a file (eg. newsy.swf)
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.