Preload an array of movie clips

If I have an array of MC names …

myClips = new Array ("clip1.swf", "clip2.swf ...... "clipN.swf");

and I want to preload them all, with a percentage loader bar, how do i do this???

I’m thinking a for loop to sum getBytesTotal() for each clip, then another for loop for getBytesLoaded…


onClipEvent (enterFrame) {
loaded=0;
total=0;
for(i=0;i<=myClips.length();i++) {
total+=getBytesTotal();
loaded +=getBytesLoaded();
} //for
percentage = Math.Ceiling (loaded/total*100);
//
//graphics nonsense here;)
//
if (percentage ==100) gotoAndStop(wherever);
}//enterframe

is that making sense to anyone ??
i’m in work so haven’t got flash to test this - - sorry

thanks for your time
chris

I dont know if that would work. In my mind the clips in your array are just names. As in just strings of letters and not the actual swf’s. Therego you can’t preload them the way your trying.

Saying that i’m not too clear on what your trying to do? Either your trying to lpreoad them all from the array or you want to know how you can show a loader bar when one of the swf’s is accessed.

If its the latter then you can simply include the script and the loader graphic at the start of each swf before the content in those swf’s.

Regards,
Viru.

ermmm,
code it wrong anyway…
but i’m trying to load all of them all before i goto navigation


onClipEvent (enterFrame) {
doneOnce=false;
loaded=0;
total=0;
for(i=0;i<=myClips.length();i++) {
if (!doneOnce) {
createEmptyMovieClip(myClips*, "holdermc"+i, 1200+i);

total  += this.[holdermc+"i"].getBytesTotal();
loaded += this.[holdermc+"i"].getBytesLoaded();
}
} //for
doneOnce=true;

for(i=0;i<=myClips.length();i++) {
loaded +=this.[holdermc+"i"].getBytesLoaded();
} //for

percentage = Math.Ceiling (loaded/total*100);
//
//graphics nonsense here
//
if (percentage ==100) gotoAndStop(wherever);
}//enterframe

does that make more sense?

Not saying this will work, but its what i’d change.

Put this in the root timeline, otherwise it will be reset on each onEnterFrame execution;

[AS]
doneOnce=false;
loaded=0;
total=0;
[/AS]

This applied to your root timeline also.
[AS]
this.onEnterFrame {

if (!doneOnce) { // Does it once only. Creates a mc to hold each external swf.
    for(i=0;i&lt;myClips.length();i++) {
        _root.createEmptyMovieClip(myClips*+"holder", 1200+i);

        total  += _root[myClips*+"holder"].getBytesTotal();
        loaded += _root[myClips*+"holder"].getBytesLoaded();
    }
} //for

doneOnce=true;

for(i=0;i&lt;myClips.length();i++) {
    loaded += _root[myClips*+"holder"].getBytesLoaded();
} //for

percentage = Math.round (loaded/total*100);
//
//graphics nonsense here
//
if (percentage &gt;= 100) gotoAndStop(wherever);

}//enterframe
[/AS]

Well thats what i’d change, let me know if that works.

Regards,
Viru.

I’ll try that when i get back from work - probably reply in about 8 hours - - -argh.

thanks for you help viru

chris