PDA

View Full Version : Several external JPEGS - one preloader?


ykarmi
03-07-2007, 08:10 PM
Hey Guys!
I have a flash file loading several external files.
I'm facing two problems:
1. **and the more important 1* Although I am loading several images, I want the preloader to be for all of them together - using a listener.
2. I want to load the images for use in the next scene, not the preloading scene, therefore I need to store them in a way that I can call them through ActionScript later on, something like Linkage, except I'm adding the Linkage in runtime.

I know how to create a preloader for one image at a time using a Movie Clip listener, but I want the preloader to show progress of the total amount of bytes loaded from all external images, not just one. Plus - if I use a MovieClip loader, the images will be loaded to a movie clip on the stage, but I want to call them using Action Script from a different scene in the movie. :eek:

Thank you very much,
Yuval Karmi :)

inhan
03-07-2007, 09:39 PM
First of all, whatever you load into a swf file remains in the cache so the next time you're loading them you won't be waiting for more than some milliseconds.

Secondly, what I would do would be to:

(X = the number of jpg's)

1. create X empty movie clips
2. create X listeners & MovieClipLoader's
3. set the alpha of each to zero
4. create a (number) variable like:
var loadedFiles:Number = 0;

5. within "onProgress" event handler of each, write a function like:

listener1.onProgress = function(mc:MovieClip, loaded:Number, total:Number) {
var percent:Number = Math.round(loaded/total*100);
preloader.bar._xscale += percent/X;
statusT.text += loaded;
};
listener1.onLoadComplete = function(mc:MovieClip) {
loadedFiles++;
if (loadedFiles == X) {
for (i=0; i<loadedFiles; i++) {
_root["emptyMcName"+i]._alpha = 100;
}
}
};Percentage line might need editing, but this theorically (maybe with a bit of change) should work, I guess...

ykarmi
03-07-2007, 10:08 PM
First of all Thank you for posting. I really appreciate it.
In this case, the preloader will finish loading one picture, then restart again from 0 - 100, loading the next picture. I don't want that, I want something like this:
Say I have 10 images, then if 1/10 images was loaded, the preloader will show 10 percent done.
Thank you again!
Yuval :)

inhan
03-07-2007, 11:30 PM
That's why I wrote "bar._xscale += percent/X" and all that.

inhan
03-08-2007, 01:33 AM
I'm trying to do what I suggested. I'll write back when I succeed ;)

inhan
03-08-2007, 03:41 AM
Okay here is the file.