# Image preloader not working properly

**URL:** https://forum.kirupa.com/t/image-preloader-not-working-properly/17205
**Category:** Uncategorized
**Created:** [April 2, 2003, 4:43pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205 "2003-04-02T16:43:08Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![shuga](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@shuga](https://forum.kirupa.com/u/shuga)
#### Post date: [April 2, 2003, 4:43pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/1 "2003-04-02T16:43:08Z")

</div>

alright, here’s the problem

you click the button for the first image, it loads with preloader and everything is perfect, you click the second image, it loads but no preloader is shown

i thought it was a problem with the levels but i changed each script first to an incrementing variable and then to a static number, each with their own number, but that didn’t work.

i think it might be that the old “preloader” and “container” symbols are still active but i’m not sure

here’s the code i’m using.

```php

this.createEmptyMovieClip("preloader", 1000);
this.createEmptyMovieClip("container", 2000);

preloader.onEnterFrame = function() {
        var l = container.getBytesLoaded();
        var t = container.getBytesTotal();
        var getPercent = l/t;
        loadText = Math.round(getPercent*100)+"%";
        loadBar._width = getPercent*160.5;
        if (l>0 && l>=t) {
                container._visible = 1;
                delete loadText;
                loadBar._visible = 0;
}
}

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 6:13pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/2 "2003-04-02T18:13:43Z")

</div>

Why do you delete loadText??? You don’t want to delete it, you want to clear it.

[AS]loadText = “”[/AS]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 6:50pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/3 "2003-04-02T18:50:21Z")

</div>

ok … i made that change

problem still not fied though 😊

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 6:51pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/4 "2003-04-02T18:51:56Z")

</div>

How do you get the loadBar to be visible again?

You make it \_visible = 0 when it fully loads, but how do you make it visible again? Is that an action on the button to load the images?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 6:59pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/5 "2003-04-02T18:59:35Z")

</div>

_shrug_  
i got the script from you [http://www.kirupaforum.com/forums/showthread.php?s=&threadid=15472&perpage=15&pagenumber=2](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=15472&perpage=15&pagenumber=2)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 7:00pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/6 "2003-04-02T19:00:33Z")

</div>

oh oh … i think i put that in there so they would disappear after the load was complete.

how do i make them come back?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 7:02pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/7 "2003-04-02T19:02:10Z")

</div>

Yeah, but I never made the loadBar invisible, that was something you added 😉

You set loadBar.\_visible = 0 when the image is done loading.

If you don’t set it back to 1 so it is visible again, you won’t see it 😛

So I am assuming that on the buttons before you load the image you also need to reset loadBar\_visible back to 1.

[edit]replied at the same time…lol[/edit]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 7:05pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/8 "2003-04-02T19:05:10Z")

</div>

alright i took that line out and the text still disappears b/c i set it = “” and the loadbar doesn’t go away after it’s done loading … but it does work when you load another image … it just stays there

[http://www.aaronsleeper.com](http://www.aaronsleeper.com) … go to the ‘design’ section to see what i’m talking about

…edit…  
replied at the same time … lol  
i’ll go make those changes real quick

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 7:09pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/9 "2003-04-02T19:09:12Z")

</div>

here’s what i have now

```php

this.createEmptyMovieClip("preloader", 1000);
this.createEmptyMovieClip("container", 2000);

container._visible = 0;
loadBar._visible = 1;

with (container) {
        loadMovie(_root.picture);
        _x = 240;
        _y = -60;
        _xscale = 35;
        _yscale = 35;
        _visible = false;
}
preloader.onEnterFrame = function() {
        var l = container.getBytesLoaded();
        var t = container.getBytesTotal();
        var getPercent = l/t;
        loadText = Math.round(getPercent*100)+"%";
        loadBar._width = getPercent*160.5;
        if (l>0 && l>=t) {
                container._visible = 1;
                loadText = ""
                loadBar._visible = 0;

```

but it’s still not working (doing the same thing it was doing before i posted actually.

i probably put stuff in the wrong place =)

…edit…  
i forgot to update the swf file on the server before i tested … lol  
ok so now the loadbar works the way it’s supposed to on each image but the text doesn’t come back each time

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 7:12pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/10 "2003-04-02T19:12:32Z")

</div>

I don’t see anything wrong with it man.

Try clearing your cache because your loaded images are being cached so they are probably loading so quick you can’t see the load process.

They worked perfectly fine for me.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 7:18pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/11 "2003-04-02T19:18:13Z")

</div>

right it works … the loadBar does it’s thing and the images load … but the numbers only show up on the first image i load … the other images have the loadbar but no percentage

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 7:29pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/12 "2003-04-02T19:29:46Z")

</div>

text isn’t showing b/c it’s the same color as the bg … 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 7:35pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/13 "2003-04-02T19:35:50Z")

</div>

So everything all fixed now?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 7:45pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/14 "2003-04-02T19:45:46Z")

</div>

yep yep =)

thank you very much for the help:chinaman:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [April 2, 2003, 7:48pm UTC](https://forum.kirupa.com/t/image-preloader-not-working-properly/17205/15 "2003-04-02T19:48:54Z")

</div>

No problem, glad you got it working 🙂
