Need help with preloader

Hi

i built a script that places a jpg and a preloader on the seen, i’d like the preloader to be removed from the moment the jpg is loaded.

I thought this code would be working, but apparently it isn’t. my preloader is already removed before my jpg is loaded.

Can somebody help me.

this.createEmptyMovieClip("thumbnail", 1);
this.attachMovie("preloader", "preloader", 2);
thumbnail.loadMovie("toonzaal.jpg");
preloader.onEnterFrame = function() {
	if (thumbnail.getBytesLoaded() >= thumbnail.getBytesTotal()) {
		this.unloadMovie();
	}
}

i made little modifications to your code to show how it works

this.createEmptyMovieClip("thumbnail", 1);
this.attachMovie("preloader", "preloader", 2);
thumbnail.loadMovie("/images/463526_klavier.jpg");

preloader.onEnterFrame = function() {
    loading = thumbnail.getBytesLoaded();
    total = thumbnail.getBytesTotal();
    
    // "pre" is the clip in the progress bar to show the progress
    // and "base" is the background of the preload, so it has the "width"

    percent = loading/total*100;
    this.pre._width = loading/total*this.base._width;
    if (percent == 100) {
        trace("end of preload")
        
        // you wish delete this dunction
        // or unload the preloader when finish
        
        //delete this.onEnterFrame;
        unloadMovie(preloader)
    }
}

good luck

Hi

here is my code again, i still have some troubles.

when I test yours as it is, it works perfectly, but when i change the code cause i’m using an array, it doesn’t work anymore.

	thumbs["thumb"+i].productPreview.loadMovie("pics/kachels_"+kachels*+"_s.jpg");
	thumbs["thumb"+i].preloader.onEnterFrame = function() {
		loading = thumbs["thumb"+i].productPreview.getBytesLoaded();
		total = thumbs["thumb"+i].productPreview.getBytesTotal();
		percent = loading/total*100;
		if (percent == 100) {
			unloadMovie(thumbs["thumb"+i].preloader)
		}
	}

first of all make a trace of this:

if (percent == 100) {
trace(“what´s happening??”)
unloadMovie(thumbs[“thumb”+i].preloader)
}

and i think you are trying tu unload a movie with code inside himself… i mean:

When you are inside “thumbs.preloader” if you say “unload(thumbs.preloader)”, the script is trying to find a clip named thumb inside him… so it don´t works.
Try put this “unload(_root.thumbs.preloader)” so you are calling it from the root of the movie, but if you are loading thinks one inside otheres or something like that, try put “_parent”

Luck