Preloading jpegs

Well, I’ve tried searching and have found code that I thought would do the trick for me, but I still have had no luck getting anything to load. What I’m trying to do is simple but I just can’t seem to find a clear answer on how to accomplish this. I’ve loaded jpegs into my main movie before, but I’ve always created swf files of the jpegs with its own independent preloader on the first frame of the swf. This seems to work fine but it does get quite tedious having to create all of these swf’s. I would like to beable to have a folder present on the server where I can just through in some random jpegs and the main movie will then show and hide a preloading bar showing the progression of the jpeg that is loading. This has to be possible…please help!

Thanks in advance…

From what everyone has been telling me this code should work, but I still only get a glimpse of the preloader bar and then it goes away, indicating to me that it is not correctly reading the bytes being loaded.

One thing I found out recently with a similar topic is that if your JPGs were saved using the “progressive” format, then they wont show up even if your code is correct. Not sure if that is your problem, but just figured I would throw that into the ring.

It works perfectly, but you have to watch it on the net, if you watch it off-line it loads right away. Also, I would add this piece of code just below the first line:[AS]loadBar._xscale = 0;[/AS]Else it will jump from 100 to 0 and then load it. Also remove the actionscript on the dummy-mc because that’s some of my old code, that I should have removed.

I don’t know if you are seeing something I’m not, but I have uploaded it to my website for testing purposes and it just will not work. Clear your internet cache and then check out www.brocksuska.com

I’ve also tried tracing dummy.getBytesLoaded and dummy.getBytesTotal and the first time I check it, it throws a 4 in the ouput window. Then if I trigger it again it will read the correct amount of bytes. Not sure what is up with that???

change the if-condition to this:[AS] if (dummy.getBytesLoaded()>=dummy.getBytesTotal() and dummy.getBytesLoaded()!=4) {
loadBar._visible = 0;
}[/AS]

Tried this bit of code and tested it…same result. Now I tried just deleting the loadBar._visible = 0 if statment and it works fine, but of course the load bar doesn’t go away. So I need to figure out an if statement here to hide the bar once all the info if loaded…

I’ve found the problem change the if-condition to:[AS] if (dummy.getBytesLoaded()>=dummy.getBytesTotal()) {
loadBar._visible = 0;
**} else {
loadBar._visible = 1;
**}[/AS]so just add the bold text, this way, your mc will show up again when it is loading something…

Well, I tried that and was rejected once again. Here is the code again just to make sure we are on the right path…

loadBar._visible = 0;
if (dummy.getBytesLoaded()>=dummy.getBytesLoaded()) {
loadBar._visible = 0;
} else {
loadBar._visible = 1;
}
blueButton.onRelease = function() {
loadMovie(“abe.jpg”, dummy);
loadBar._visible = 1;
loadBar._xscale = 0;
};
this.onEnterFrame = function() {
loadBar._xscale = dummy.getBytesLoaded()/dummy.getBytesTotal()*100;
if (dummy.getBytesLoaded()>=dummy.getBytesLoaded()) {
loadBar._visible = 0;
} else {
loadBar._visible = 1;
}
};

Whoops this is the actual code I’m trying to use…

loadBar._visible = 0;
blueButton.onRelease = function() {
loadMovie(“abe.jpg”, dummy);
loadBar._visible = 1;
loadBar._xscale = 0;
};
this.onEnterFrame = function() {
loadBar._xscale = dummy.getBytesLoaded()/dummy.getBytesTotal()*100;
if (dummy.getBytesLoaded()>=dummy.getBytesLoaded()) {
loadBar._visible = 0;
} else {
loadBar._visible = 1;
}
};

p.s. How do you paste your code in so it has all the styles and fonts there?