# Preloading Dinamicaly loaded images

**URL:** https://forum.kirupa.com/t/preloading-dinamicaly-loaded-images/13008
**Category:** flash
**Created:** [February 7, 2003, 1:20pm UTC](https://forum.kirupa.com/t/preloading-dinamicaly-loaded-images/13008 "2003-02-07T13:20:42Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![tstefan](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tstefan](https://forum.kirupa.com/u/tstefan)
#### Post date: [February 7, 2003, 1:20pm UTC](https://forum.kirupa.com/t/preloading-dinamicaly-loaded-images/13008/1 "2003-02-07T13:20:42Z")

</div>

I have a problem with preloading dinamicaly loaded images, like jpg’s. I can’t get total and loading bites.  
Does somebody knows how to solve this probelem or maby somebody have done it.  
Thanks  
😉 😉 😏

---

<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: [February 7, 2003, 3:30pm UTC](https://forum.kirupa.com/t/preloading-dinamicaly-loaded-images/13008/2 "2003-02-07T15:30:01Z")

</div>

ok … you load the jpg file into a mc. let’s call it **container**

it’s the same method you would do it loading a swf

Bloaded = \_root.container.getBytesLoaded()  
Btotal = \_root.container.getBytesTotal()

that’s it … 🙂

if you don’t get it post your fla 😏

---

<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: [February 7, 2003, 7:37pm UTC](https://forum.kirupa.com/t/preloading-dinamicaly-loaded-images/13008/3 "2003-02-07T19:37:08Z")

</div>

I have try that, bu it doesn’t work.  
I get only total bytes of empty movie clip.

---

<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: [February 7, 2003, 7:39pm UTC](https://forum.kirupa.com/t/preloading-dinamicaly-loaded-images/13008/4 "2003-02-07T19:39:53Z")

</div>

> if you don’t get it post your fla

😉

---

<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: [February 7, 2003, 7:42pm UTC](https://forum.kirupa.com/t/preloading-dinamicaly-loaded-images/13008/5 "2003-02-07T19:42:37Z")

</div>

i forgot … you’ll need to test it in your server !!  
it won’t work in the streaming mode in flash (-:

---

<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: [February 7, 2003, 8:03pm UTC](https://forum.kirupa.com/t/preloading-dinamicaly-loaded-images/13008/6 "2003-02-07T20:03:11Z")

</div>

Well it’s working now, it works in this form:

\_root.bar.onEnterFrame = function() {  
bytes\_loaded = root.cont.getBytesLoaded();  
bytes\_total = \_root.cont.getBytesTotal();  
getPercent = bytes\_loaded/bytes\_total;  
this.\_width =Math.floor(getPercent\*100);  
};

you can see the result at:

[http://www.inet.hr/~tstefan/posao/](http://www.inet.hr/~tstefan/posao/)

---

<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: [February 7, 2003, 8:06pm UTC](https://forum.kirupa.com/t/preloading-dinamicaly-loaded-images/13008/7 "2003-02-07T20:06:47Z")

</div>

that’s great 🙂

glad you worked it out =)

---

<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: [February 7, 2003, 10:46pm UTC](https://forum.kirupa.com/t/preloading-dinamicaly-loaded-images/13008/8 "2003-02-07T22:46:28Z")

</div>

How did you get the grey bar to display while loading each jpg file? This is what I’m looking for.

---

<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: [February 8, 2003, 1:55am UTC](https://forum.kirupa.com/t/preloading-dinamicaly-loaded-images/13008/9 "2003-02-08T01:55:34Z")

</div>

I dont have time to go into detail, I’m about to head out the door, but I did something like what you’re asking…  
go to

[http://web.mit.edu/lavaboy/www/album/album.html](http://web.mit.edu/lavaboy/www/album/album.html)

I have the code of the whole thing there, but here’s a quick explanation:

```php

this.onEnterFrame=function(){
percent= Math.round((contain.getBytesLoaded()/contain.getBytesTotal())*100);
perbox.text = percent+"% loaded";
loadBar._width = percent;
}

```

basically, I made a bar - converted it to a movie clip and named the instance loadBar - and on enterframe I change the width of it according to the percent. I also write down the percent loaded on the textbox called perbox.

Contain is the name of the movie clip into which I dynamically load the jpegs

I guess I did have time to go into detail. I hope this helps
