Preloading Dinamicaly loaded images

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
:wink: :wink: :smirk:

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 … :slight_smile:

if you don’t get it post your fla :smirk:

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

if you don’t get it post your fla

:wink:

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

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/

that’s great :slight_smile:

glad you worked it out =)

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

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

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


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