• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • Last Modified:

preloading jpgs

hi there,

i have an app which loads several jpgs and once all are loaded, resizes an mc to reveal them.

the code is fairly complex, but basically, i use an onEnterFrame to track the bytes loaded against bytes total for all the jpgs (all fairly standard preloading stuff). and i have done ALOT of debugging around this stuff to find that it does only run the reveal script once all are supposedly loaded. however, i am getting blank spaces for a few seconds on some for their first loads in the live environment, which must mean that they are not completely loaded.

i remembered having a similar problem a few years back and putting it down to flash's loading of jpgs at the time, but i can't accept that is the case after so long as i am sure it would have been sorted out by now.

so, i am hoping someone might have an idea where i might be going wrong, or, if it isn't me, then perhaps a workaround that could solve this.
i would post the code if it weren't so complex... it'd take someone hours to figure out what's going on in there, so i can only hope this is something someone else has experienced before and found a solution to.

btw... am working for MX (flash 6) if it makes a difference.

thanks,
nikki
0
nifmcm
Asked:
nifmcm
2 Solutions
 
Ramy_atefCommented:
Hi
If you can use at least flash 7, then most of your problems would gone..
there is a  funciton called :
MovieClipLoader

with it you can do many things like:
onLoadComplete
onLoadError
onLoadInit
onLoadProgress
onLoadStart

getProgress which Returns the number of bytes loaded and the total number of bytes of a file that is being loaded

loadClip Loads a SWF, JPEG, progressive JPEG, unanimated GIF, or PNG file

if you won't use flash 7, then i think u better add your jpgs into a flash movie, and convert them into movie clips (don't forget to name its instances so u can control them later) , after doing so, you publsih you movie .
you have now a swf containing all the jpgs you want...
from the main movie, you can load the jpgs movie like nay ordinary movie (u can do a preloader ..etc)
when the jpgs movie is loaded , you can user the jpgs inside using its instances name ..

I hope this is clear for u

Regards,
Ramy


0
 
rythmik1Commented:
I have this code from a photogallery I built a while back, it works for me and never shows the jpg's too early. Maybe something in here can help you.

stop();
//****************************************************************//
// SET JPG MC TO 100% SCALE
//****************************************************************//
            _root.jpgMc._xscale = 100;
            _root.jpgMc._yscale = 100;
//****************************************************************//
// SET MAXIMUM WIDHT / HEIGHT OF LOADED JPG
//****************************************************************//
            maxWidth = 380;
            maxHeight = 319;

//****************************************************************//
// LOAD IMAGE
//****************************************************************//
            _global.currentImage = _global.imgXML[_global.img].attributes.Image;
            _root.jpgMc._alpha = 0;
            this.onEnterFrame = function() {
                  //load bar
                  totBytes = eval(jpgMc).getBytesTotal();
                  actBytes = eval(jpgMc).getBytesLoaded();
                  percent = Math.round(actBytes*100/totBytes);
                  _root.loadingJpg.loadbar._xscale = percent;
                  _root.loadingNextPic_txt.text = "Loading Next Picture";
                  if(percent>0) {
                        _root.loadingJpg._alpha = 100;
                  }
                  if (percent>99) {
                        _root.loadingJpg._alpha = 0;
                        _root.caption.text = _global.imgXML[_global.img].attributes.Caption;
                        _root.loadingNextPic_txt.text = "";
                        _root.jpgMc._alpha = _root.jpgMc._alpha+20;
                        
                        if (_root.jpgMc._alpha>99) {
                              delete (this.onEnterFrame);
                        //****************************************************************//
                        // SHRINK IMAGE IF IT IS TOO BIG TO FIT IN FLASH AREA
                        //****************************************************************//
                        if (_root.jpgMc._height>maxHeight) {
                              _root.jpgMc._height = maxHeight;
                              _root.jpgMc._xscale = _root.jpgMc._yscale;
                        }
                        if (_root.jpgMc._width>maxWidth) {
                              
                              _root.jpgMc._width = maxWidth;
                              _root.jpgMc._yscale = _root.jpgMc._xscale;
                        }
                              _root.frame._width = _root.jpgMc._width+8;
                              _root.frame._height = _root.jpgMc._height+8;
                              _root.frame._alpha=100;                              
                              _root.jpgMcLoaded.loadMovie(_global.domain+"/images/"+_global.currentImage);
                              _root.jpgMcLoaded._yscale=_root.jpgMc._yscale;
                              _root.jpgMcLoaded._xscale=_root.jpgMc._xscale;
                              gotoAndPlay(9);
                        }
                  }
            };
_root.jpgMc.loadMovie(_global.domain+"/images/"+_global.currentImage);
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now