Preloader for my script? Can it be done?

I ahve this random picture generator which loads into a emply MC but on a 56k connection the picture takes too lond to appear can i preload the image with the script too?

picTotal = 18;
// adjust per total pics, img1.jpg,…,imgN.jpg, where N=picTotal
name1 = “img”+Math.ceil(Math.random()*picTotal)+".jpg";
loadMovie(name1, _root.BG);
preloadI = setInterval(preloadF, 10);
function preloadF() {
if (_root.BG.getBytesLoaded()>=_root.BG.getBytesTotal()) {
// reference the target level or clip.
_root.BG._x = 0;
// lines up your background pics.
_root.BG._y = 0;
clearInterval(preloadI);
}
}

i have no idea how to do it?

search preload + image :slight_smile:

This should work. Create a textfield with the instance name info:

picTotal = 18;
// adjust per total pics, img1.jpg,...,imgN.jpg, where N=picTotal
name1 = "img"+Math.ceil(Math.random()*picTotal)+".jpg";
function preload(clip, x, y) {
        this.createEmptyMovieClip("temp", 1000);
        temp.onEnterFrame = function() {
                var t = clip.getBytesTotal(), l = clip.getBytesLoaded();
                if (t) {
                        var percent = Math.round(l*100/t);
                        if (l == t) {
                                info.text = "Done Loading";
                                clip._x = x;
                                clip._y = y;
                                this.removeMovieClip();
                        } else {
                                info.text = percent+" %";
                        }
                }
        };
}
BG.loadMovie(name1);
preload(BG, 0, 0);