PDA

View Full Version : Loads but don't pre-loads



jazzmatazz2005
09-12-2004, 01:27 AM
when users come to my site i want a different Flash movie to load. The action script that im useing is

filename = ["mainarea.swf", "mainarea2.swf", "mainarea3.swf"];
path = "http://www.rockdamic.com/main/animation/";
i = filename.length;
k = Math.floor(Math.random()*i);
loadMovie(path+filename[k], movieTarget);
The problem is i already have the flash movies created and they all have preloaders but when the action script call for the movie it doesn't preload all i get is a hugh white box and then finally the movie shows up. I wan it to preload. Do anyone have any ideas on how i can fix this.

poab
09-27-2004, 09:13 AM
Hi,

The problem you are having is that a movie clip will only play when it is fully loaded. In other words, your preloader scripts are running, but they don't run until the entire thing is loaded, meaning that the getBytesLoaded() and the getBytesTotal() (I assmue that's how you're doing it) are already equal and therefore the preloader animation doesn't show.

What you need to do is remove the preloaders from the movies you're loading (they're worthless where they are) and put the preloader into the main swf.

I'm not going to go into the onData and onLoad event handler debacle but they're useless to you here so don't bother with them. If you search for them you'll find plenty of info.

Basically here's roughly what you need (you'll need to tailor it - it's AS1.0).

filename = ["mainarea.swf", "mainarea2.swf", "mainarea3.swf"];
path = "http://www.rockdamic.com/main/animation/";
i = filename.length;
k = Math.floor(Math.random()*i);
loadMovie(path+filename[k], movieTarget);
pauseloader = setInterval(loader, 500);
function loader(){
var lb = movieTarget.getBytesLoaded();
var tb = movieTarget.getBytesTotal();
trace("bytes loaded = " + lb);
trace("bytes total = " + tb);
if(lb>=tb){
clearInterval(pauseLoader);
}
}

cheers.