5 Replies Latest reply on Jan 15, 2007 10:04 AM by bcraigie

    preloading an external .swf

      is it possible to preload an external .swf from the main movie while the preloader routine stays in the main movie, not in the external clip? it does not work in my case ... I may do something wrong ...

      I have a mc called "loader" on the main timeline in the main movie.
      I want to preload an external .swf called "animation.swf"
      on the first frame I have:

      preloaderbar._xscale = 0;

      on the second frame:

      BytesTotal = loader.getBytesTotal();
      BytesLoaded = loader.getBytesLoaded();
      Bytes = Math.round(100*BytesLoaded/BytesTotal);
      preloaderbar._xscale = Bytes;

      on the third:

      if (Bytes<100) {
      Bytes = Bytes+1;
      } else {

      the external clip is beeing loaded, ofcourse (loader.loadMovie("animation.swf");), but the progress bar is not increasing at all ....

      What do I do wrong?

        • 1. Re: preloading an external .swf
          Level 7
          Where are you testing this? Locally, it'll load nearly instant and so you're
          not going to see the preloader action. Also, you have Bytes = Bytes + 1 in
          your third frame? It's not doing anything, and should be removed - and you
          can write it as: Bytes++; - but still it's wrong to have there. I always
          suggest people use the MovieClipLoader class instead of LoadMovie. You can
          do the preloader calcs in the onLoadInit method then, and you can do this in
          one frame instead of three.

          Dave -
          Head Developer
          Adobe Community Expert

          • 2. Re: preloading an external .swf
            var mInterval=setInterval(this,"checkLoaded",100);
            function checkLoaded(){
            Bytes = Math.round(100*loader.getBytesLoaded()/loader.getBytesTotal());
            preloaderbar._xscale = Bytes;
            • 3. Re: preloading an external .swf
              gringito Level 1
              ay! :) thats it! thank you very much guys! especially to Mohammed Fasil A.K :)
              • 4. Re: preloading an external .swf
                gringito Level 1
                well ... :/ ... while testing the Mohammed Fasil A.K script I have found out that it works correctly only with large (data) size files ...

                in my case, if the loaded file was less than 30 kB, it did not work . the file has loaded up, that was correct, but the progress bar was not working at all.

                my speed connection is pretty fast (DSL), I guess it might be important - the speed of connection together with the size of the file ...

                I made another test, I was loading 200 kB file and everything was correct ...
                but unfortunally I need to load a file of any size ...

                can anyone help?
                • 5. Re: preloading an external .swf
                  bcraigie Level 1
                  Of course you won't see the progress bar with a 30K file because it will load so fast you won't have time to see it. It still work, but you only see it when it needs to be seen, which is exactly what you want.