Preloading into cache

Can you preload a swf into the users cache. ie a menu system that called external movies when selected would actually begin loading movies into cache before user selected anything but would not be revealed until button selected.

Purpose is to cut down on lag time for external swf to load.

thanks

yep, goto www.dynamicdrive.com and look for image preloaders :wink:

Thanks for the link, but as far as I could tell, dynamicdrive is just for dhtml scripts. I want to do this all in flash. Am i missing something??

oh! you want to preload other swfs ?
that’s possible
use

loadMovie(url,target);
with (target) {
getBytesLoaded() >= getBytesTotal() ? unloadMovie() : null;
}

this will cache this swf…

Invisible: Preloading your other movies in the background kind of defeats the purpose of loadMovie(). loadMovie() was created to prevent the users from having to download anything they weren’t going to see, which saves them on download time because you lower your file size. If you are going to preloader your external content all at once, you might as well be using Scenes. I recommend preloader your external movies individually as they get loaded in instead. It is much more efficient and it won’t cause lag in your movie because of things loading in the background.

Whenever you load anything from Flash it automatically throws it into the cache for later, so might as well only load it when needed instead of right off the bat.

fluid_0ne: And that will…? check the movie only once when that frame is hit?

I think you mean to do something like this instead… [AS]loadMovie(url,target);
target.onEnterFrame = function(){
this.getBytesLoaded() >= this.getBytesTotal() ? (this.unloadMovie(), delete this.onEnterFrame) : null;
}[/AS]

But as stated before, this method is quite inefficient and will cause lag in the main movie while other stuff is loading in the background.

i tohught he’ll get that it mus be onEnterFrame…

not quite… it makes sense i think if you want already something to be visible and usable by the visitor, while under water you load already some swf’s that the user will play later on… simply to let the site run more smooth and not drowning in preloader bars…

or is there a better way of doing that???

*Originally posted by lostinbeta *
**Invisible: Preloading your other movies in the background kind of defeats the purpose of loadMovie(). loadMovie() was created to prevent the users from having to download anything they weren’t going to see, which saves them on download time because you lower your file size. If you are going to preloader your external content all at once, you might as well be using Scenes. I recommend preloader your external movies individually as they get loaded in instead. It is much more efficient and it won’t cause lag in your movie because of things loading in the background.

Whenever you load anything from Flash it automatically throws it into the cache for later, so might as well only load it when needed instead of right off the bat.

fluid_0ne: And that will…? check the movie only once when that frame is hit?

I think you mean to do something like this instead… [AS]loadMovie(url,target);
target.onEnterFrame = function(){
this.getBytesLoaded() >= this.getBytesTotal() ? (this.unloadMovie(), delete this.onEnterFrame) : null;
}[/AS]

But as stated before, this method is quite inefficient and will cause lag in the main movie while other stuff is loading in the background. **

Hi guys,

will you tell me what is the final code to solve this problem

thanks