Preloader issue

Hi everybody,

I have this code for the start frame of a movie. In it, I am trying to load a jpg image, and have a preloader showing the loading progress of both items: my movie and the jpg image. Then when the movie is fully loaded, and the jpg is fully loaded as well, the movie should play.

For some reason it is not working. I have tried several ways and it just doesn’t work.

Can anyone help me with this?

Thanks


stop();
//
var randomNumber:Number = 1 + random(7);
var randomBackground:String = "background_image.jpg";
background_mc.createEmptyMovieClip("imageHolder_mc", 1);
background_mc.imageHolder_mc.loadMovie(randomBackground);
background_mc._visible = false;
//
//PRELOADER
this.onEnterFrame = function() {
	loadedB = background_mc.imageHolder_mc.getBytesLoaded();
	totalB = background_mc.imageHolder_mc.getBytesTotal();
	totalBytes = this.getBytesTotal() + totalB;
	loadedBytes = this.getBytesLoaded() + loadedB;
	if (loadedBytes != totalBytes) {
		this.preloader_mc._visible = true;
		percent = Math.floor(100 * loadedBytes / totalBytes);
		preloader_mc.preloaderBar_mc._xscale = percent;
		preloader_mc.percent_txt.text = percent + "%";
	} else {
		preloader_mc._alpha -= 10;
		if (this.preloader_mc._alpha <= 0) {
			delete this.onEnterFrame;
			_root.gotoAndPlay(4);
		}
	}
};