# Preloader issue

**URL:** https://forum.kirupa.com/t/preloader-issue/154856
**Category:** flash
**Created:** [July 13, 2005, 5:50am UTC](https://forum.kirupa.com/t/preloader-issue/154856 "2005-07-13T05:50:55Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![CayoHueso](https://avatars.discourse-cdn.com/v4/letter/c/8e8cbc/32.png) [@CayoHueso](https://forum.kirupa.com/u/CayoHueso)
#### Post date: [July 13, 2005, 5:50am UTC](https://forum.kirupa.com/t/preloader-issue/154856/1 "2005-07-13T05:50:55Z")

</div>

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

```auto

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);
		}
	}
};

```
