Un metodo per fare un preloader con resize di un'immagine può essere il seguente:
codice:
MovieClip.prototype.preloadImage = function(img){
if(img != undefined && (img.substr(img.length - 4, img.length) == ".jpg")){
this.attachMovie("bar", "bar", 2);
this.bar._xscale = 0;
this.createEmptyMovieClip("container", 1);
this.container._alpha = 98;
this.container.loadMovie(img);
this.onEnterFrame = function(){
var car = this.container.getBytesLoaded();
var tot = this.container.getBytesTotal();
if(car != undefined && car > 100){
var perc = Math.round(((car / 1024) * 100) / (tot / 1024));
this.bar._xscale = perc;
if(car >= tot){
this.bar.removeMovieClip();
this.container._height = this.container._width = 80;
delete this.onEnterFrame;
}
}
};
}else trace("ERRORE: nessuna immagine o file non valido!");
};
this.createEmptyMovieClip("test", 1);
test.preloadImage("img.jpg");