10 Replies Latest reply on Jul 11, 2010 3:32 AM by MoshMage

    Preloader not working althought it loads fine

    MoshMage

      im trying to make a preloader, althought it loads just fine the preloader bar wont move, better: the filesize against the loaded bytes does not let it move

       

      http://pastebin.com/SLQeqx7U code is there, i dont know if this forums have [code] thing

        • 1. Re: Preloader not working althought it loads fine
          kglad Adobe Community Professional & MVP

          you can copy and paste (limit the amount) code to this forum.

          • 2. Re: Preloader not working althought it loads fine
            MoshMage Level 1

            ok, so.. i'd guess this is what's needed. anymore info and the url will provide.

             

             

            1. this.onEnterFrame=function() {
            2.         while(_global.loadCount) {
            3.                 for (il=0;il<_global.image.length;il++) {
            4.                         trace("for  Image "+il+" "+_global.image[il]+" "+_global.limage[il]);
            5.                         if (_global.limage[il]==0) {
            6.                                 trace("limage  preview: "+prever)
            7.                                  nprever._x=500;
            8.                                 _global.limage[il]=1;
            9.                         }
            10.                         if (_global.limage[il]==1) {
            11.                                 v=il+1
            12.                                 wprel=_root.tfcore["preloader_"+v];
            13.                                 wprev=_root.tfcore["preview_"+v];
            14.                                 trace("wprel:  "+wprel+" wprev: "+wprev);
            15.                                  filesize = wprev.getBytesTotal();
            16.                                 loaded = wprev.getBytesLoaded();
            17.                                 wprel.visible=true;
            18.                                 trace("loaded:"+loaded);      
            19.                                 trace("filesize:"+filesize);
            20.                                 if (loaded != filesize) {
            21.                                          wprel.bar._xscale=100*loaded/filesize;
            22.                                          wprel.preload_text.text=""+Math(100*loaded/filesize)+"%";
            23.                                          loaded = wprel.getBytesLoaded();
            24.                                          trace("### Loading "+Math(100*loaded/filesize)+"%");
            25.                                 }
            26.                                 else {
            27.                                          wprel.visible=false;
            28.                                          _global.limage[il]=2;
            29.                                          _global.loadCount-=1;
            30.                                          while (wprev._alpha<100) {
            31.                                                  wprev._alpha += 10;
            32.                                          }
            33.                                          trace("##! Load ended");
            34.                                 }
            35.                         }
            36.                 }
            37.         }
            38. }
            • 3. Re: Preloader not working althought it loads fine
              kglad Adobe Community Professional & MVP

              1.  all those variables need to be initialized or you need to publish for fp 6 or earlier.

               

              2.  if your arrays have length greater than 1, your preloader display will not work the way you want because each loop (of your for-loop) is trying to display the load progress of one array element.

              • 4. Re: Preloader not working althought it loads fine
                MoshMage Level 1

                Erm.. and how would i check EACH array element?

                 

                2010/7/8 kglad <forums@adobe.com>

                 

                1.  all those variables need to be initialized or you need to publish for

                fp 6 or earlier.

                >

                2.  if your arrays have length greater than 1, your preloader display will

                not work the way you want because each loop (of your for-loop) is trying to

                display the load progress of one array element.

                >

                • 5. Re: Preloader not working althought it loads fine
                  kglad Adobe Community Professional & MVP

                  what are you trying to do?

                   

                  are you trying to create a preloader for the swfs in your array?  ie, you want to preloader all those swfs (and display their combined load progress)?

                  • 6. Re: Preloader not working althought it loads fine
                    MoshMage Level 1

                    yep. that's exactly what im trying to do

                     

                    2010/7/9 kglad <forums@adobe.com>

                     

                    what are you trying to do?

                    >

                    are you trying to create a preloader for the swfs in your array?  ie, you

                    want to preloader all those swfs (and display their combined load progress)?

                    >

                    • 7. Re: Preloader not working althought it loads fine
                      kglad Adobe Community Professional & MVP

                      the only reasonable way to do that is to load the swfs sequentially.  ie, don't load them in a for-loop:

                       


                      var index:Number=0;

                      loadF();

                      this.onEnterFrame=preloadF;


                      function loadF(){

                      _root.tfcore["preview_"+(index+1)].loadMovie(_global.image[index]);

                      }


                      function preloadF(){

                      var ldd:Number = _root.tfcore["preview_"+(index+1)].getBytesLoaded()/_root.tfcore["preview_"+(index+1)].getBytesTotal()

                      bar._xscale = 100*(index+ldd)/_global.image.length;

                      preload_txt.text = bar._xscale+"% Loaded";

                      if(ldd>=1){

                      index++;

                      if(index<_global.image.length){

                      loadF();

                      } else {

                      delete this.onEnterFrame;

                      // loading is complete.  do whatever

                      }

                      }

                      }

                      • 8. Re: Preloader not working althought it loads fine
                        MoshMage Level 1

                        Oi oi, thanks for your time. Sorry for the late answer but i was awake 2 days in a row, i tumbled down and just woke up.

                         

                        Ill try that, and yes -- it makes more sense like that;

                         

                        thanks once again

                        • 9. Re: Preloader not working althought it loads fine
                          MoshMage Level 1

                          Nevermind, i can attach that this.onenter when creating the preview_n

                           

                          Thanks

                           

                           

                           

                          History

                          __________________________________________________________

                           

                          Erm, sorry about me asking. And im not asking for any code now, its just:

                           

                          Im loading the images from a XML, and i already have a onEnterFrame refering to "tfcore" movieclip,

                          and the "preview_n" movieClip is inside tfcore.

                           

                          this.onEnterFrame=preloadF means EVERYTHING that enters on frame gets to loadMovie to preview_N movieclip;

                           

                          the pics wont load; so, i was thinking:

                           

                          check to see if "preview_" isin "this" when entering frame, and THEN load the thing. right?

                          • 10. Re: Preloader not working althought it loads fine
                            MoshMage Level 1

                            Mate, im sorry. I dont know what im doing wrong, but the thing wont .. go. explaining;

                             

                            i have the this.onEnterFrame change to bogusClip.onEnterFrame (bogisClip is the createMovieClip to hold the pics)

                            and it calls preloadF just fine, but ldd and _root.--preview--.getBytesTotal and loaded doesnt work, traces undefined/NaN

                             

                            then you said not to put it on a for loop, but its in a for loop and reads the xml and gets the values on'to the array, idk. this preloader thing seems kinda

                            hard for such a small code. i must be underestimating the power of it (lol)