Preloading Random JPG's

Whats the best way to preload randomly called jpg? I have a blank movieclip on screen called “loadit”. So far this works but there is no preloader bar or anything I can call. Anyone got any suggestions?


// array of all files
filename = ["img1.jpg", "img2.jpg", "img3.jpg", "img4.jpg", "img5.jpg"];

// path to pics
path = "images/";

i = filename.length;
k = Math.floor(Math.random()*i);

// load random 
loadMovie(path+filename[k], loadit);

I’d also like the pictures to fade in once loaded but I’m sure that can wait till I’ve got it atleast functioning first eh? Baby steps right.

Please download my FLA if you like.

download >> randomloader.fla

Thanks y’all.
Ads.

Well, it works exactly the same way every other preloader works:

loadit.loadMovie (...) ;
this.onEnterFrame = function () {
  var l = getBytesLoaded () ;
  // and so on and so forth
} ;

There’s a very nice piece of code in the photo gallery tutorial :slight_smile: