# Preloader; so close and yet so far

**URL:** https://forum.kirupa.com/t/preloader-so-close-and-yet-so-far/131221
**Category:** Uncategorized
**Created:** [December 13, 2004, 8:09pm UTC](https://forum.kirupa.com/t/preloader-so-close-and-yet-so-far/131221 "2004-12-13T20:09:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![chiaroobscuro](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@chiaroobscuro](https://forum.kirupa.com/u/chiaroobscuro)
#### Post date: [December 13, 2004, 8:09pm UTC](https://forum.kirupa.com/t/preloader-so-close-and-yet-so-far/131221/1 "2004-12-13T20:09:05Z")

</div>

Hey everyone. It seems like only yesterday but I am plotting a new site and this time i’d like the preloader to … well … function properly. Since I am involved, that would be asking too much. Thats where the ever-helpful Kirupa comes in … hopefully.

Currently I am using the following code for my preloader:

[COLOR=DarkRed][SIZE=1]  
this.createEmptyMovieClip(“preloader”, 1000);  
this.createEmptyMovieClip(“container”, 1001);

myIdentifier=Math.round(Math.random()\*10000);  
container.loadMovie(“[http://www.enorme.org/peterson/pic14.jpg?uniq=](http://www.enorme.org/peterson/pic14.jpg?uniq=)”+myIdentifier);

container.\_visible = false;

preloader.onEnterFrame = function() {  
var l = container.getBytesLoaded();  
var t = container.getBytesTotal();  
if (l\>0 && l\>=t) {  
getPercent = l/t;  
loadText = Math.round(getPercent_100)+"%";  
loadBar.\_width = getPercent_900;  
container.\_visible = 1;  
delete \_root.onEnterFrame;  
}  
else {  
getPercent = l/t;  
loadText = Math.round(getPercent_100)+"%";  
loadBar.\_width = getPercent_900;  
}  
};  
SIZE][/COLOR]

the buttons use this code:

[SIZE=1][COLOR=DarkRed]on (release) {  
container.loadMovie(“[http://www.enorme.org/peterson/pic02.jpg?uniq=](http://www.enorme.org/peterson/pic02.jpg?uniq=)”+myIdentifier,1);  
}[/COLOR][/SIZE]

Technically it works but there are some pesky little issues that prevent me from jumping up and down and performing my ever popular happy dance:

A.) Apparently, I have to click on the images twice for them to load. This is the main problem.

B.) Problem 2 has to deal with the pesky NAN that appears in the loadText box; I would like to replace that with )% or something. I am working on this now … it seems simple enough.

C.) I am sure there is a solution floating around but I am also trying to get the loadBar to run a little smoother. I am sure shrinking it to a non-gargantuan size may help. Any hints?

I think thats it … for now. Please don’t pass judgement on the ‘design’ or its lack thereof, I want to get the code working before I attemt to make it look cool.

Thanks,  
Brian  
[http://www.enorme.org/peterson/](http://www.enorme.org/peterson/)
