5 Replies Latest reply on Jul 28, 2006 9:59 AM by Newsgroup_User

    Problems with preloader

    Belleal
      Greetings,
      I have a nasty little problem with the site I'm working on now. Since it is completely Flash-builded and quite heavy on content I decided to make every subpage into separate .swf file. They are still big though and I needed a preloader to show for each of them. No problem, at least not until I loaded the site on my hosting server. The problem is, the preloaders I wrote work damn good when I test them locally, but do not work when browsing the site from internet (actually, they work AFTER the .swf file is cached on the computer, but not while it is downloading). In the brief moment I can see the preloader, it shows 0 of 0 bytes loaded and NaN %... Well, since I am trying to make it work since 3 days and yet nothing, I will be happy if someone helps me. Here is the code for one of the preloaders:

      var Listener:Object = new Object();
      var MovieLoader:MovieClipLoader = new MovieClipLoader();
      MovieLoader.addListener(Listener);
      MovieLoader.loadClip("PageHome.swf", TargetMC);
      _parent.loadingBar._visible = true;
      _parent.percentNumber._visible = true;
      _parent.bytesDisplay._visible = true;
      _parent.loadingFrame._visible = true;
      _parent.loadingBar._xscale = 1;
      var loadingCall:Number = setInterval(loadingMovie, 50);
      function loadingMovie() {
      var Progress = MovieLoader.getProgress(TargetMC);
      var Percentage:Number = Math.round(Progress.bytesLoaded/Progress.bytesTotal*100);
      _parent.loadingBar._xscale = Percentage;
      _parent.percentNumber.text = Percentage+"%";
      _parent.bytesDisplay.text = "loaded "+Progress.bytesLoaded+" of "+Progress.bytesTotal+" bytes";
      if (Progress.bytesLoaded == Progress.bytesTotal) {
      clearInterval(loadingCall);
      _parent.loadingBar._visible = false;
      _parent.percentNumber._visible = false;
      _parent.bytesDisplay._visible = false;
      _parent.loadingFrame._visible = false;
      }
      }

      Thanks!
        • 1. Re: Problems with preloader
          Level 7

          "Belleal" <webforumsuser@macromedia.com> wrote in message news:eabgq7$4kf$1@forums.macromedia.com...
          > Greetings,
          > I have a nasty little problem with the site I'm working on now. Since it is
          > completely Flash-builded and quite heavy on content I decided to make every
          > subpage into separate .swf file. They are still big though and I needed a
          > preloader to show for each of them. No problem, at least not until I loaded the
          > site on my hosting server. The problem is, the preloaders I write work damn
          > good when I test them locally, but do not work when browsing the site from
          > internet (actually, they work AFTER the .swf file is cached on the computer,
          > but not while it is downloading). In the brief moment I can see the preloader,
          > it shows 0 of 0 bytes loaded and NaN %... Well, since I am trying to make it
          > work since 3 days and yet nothing, I will be happy if someone helps me. Here is
          > the code for one of the preloaders:

          You have to account for situations where the totalBytes and the loadedBytes are equal that are not valid.. like when both values are
          zero.
          Zero matching is the most common preloader failure. Another one is when they are both 12 bytes (empty movieclip size)
          Most working preloaders check for a non-zero value or a minimum size (I use 100 bytes)
          tralfaz


          • 2. Problems with preloader
            WebXperience Level 1
            if you load the preloader from the root level of your main movie clip into a hiegher level you'll see the preloader while the other clips are loading in the background. e.g.
            myMCL.loadClip("preloader.swf", 50);// in the first frame of your root movie clip.

            Then use the onLoadProgress listener. e.g. myListener.onLoadProgress = function (target_mc, loadedBytes, totalBytes);
            loadedBytes and totalBytes are broadcasted by the MovieClipLoader every time you load a movieclip.
            • 3. Re: Problems with preloader
              Belleal Level 1
              You do have right, tralfaz, but even if I check for this possibility what could I do? If the bytes are not correct the preloader is still useles and I need to work around it somehow...
              WebXperience, this sounds interesting option but I am not quite sure how to make it work if it's not working the other way. My preloader still shows on top of everything and it displays wrong when I remove the 4 lines that hide its components... It seems it cannot read the correct size of the .swf files it is about to load from the server. And I cannot imagine how is this possible since the access is not denied...
              • 4. Re: Problems with preloader
                Level 7
                If you are using MovieClipLoader, then start the preloader in the
                onLoadInit, or use the onLoadProgress to tally the progress to the parent.



                --
                Lon Hosford
                www.lonhosford.com
                Flash, Actionscript and Flash Media Server examples:
                http://flashexamples.hosfordusa.com
                May many happy bits flow your way!
                "Belleal" <webforumsuser@macromedia.com> wrote in message
                news:eabgq7$4kf$1@forums.macromedia.com...
                > Greetings,
                > I have a nasty little problem with the site I'm working on now. Since it
                > is
                > completely Flash-builded and quite heavy on content I decided to make
                > every
                > subpage into separate .swf file. They are still big though and I needed a
                > preloader to show for each of them. No problem, at least not until I
                > loaded the
                > site on my hosting server. The problem is, the preloaders I write work
                > damn
                > good when I test them locally, but do not work when browsing the site from
                > internet (actually, they work AFTER the .swf file is cached on the
                > computer,
                > but not while it is downloading). In the brief moment I can see the
                > preloader,
                > it shows 0 of 0 bytes loaded and NaN %... Well, since I am trying to make
                > it
                > work since 3 days and yet nothing, I will be happy if someone helps me.
                > Here is
                > the code for one of the preloaders:
                >
                > var Listener:Object = new Object();
                > var MovieLoader:MovieClipLoader = new MovieClipLoader();
                > MovieLoader.addListener(Listener);
                > MovieLoader.loadClip("PageHome.swf", TargetMC);
                > _parent.loadingBar._visible = true;
                > _parent.percentNumber._visible = true;
                > _parent.bytesDisplay._visible = true;
                > _parent.loadingFrame._visible = true;
                > _parent.loadingBar._xscale = 1;
                > var loadingCall:Number = setInterval(loadingMovie, 50);
                > function loadingMovie() {
                > var Progress = MovieLoader.getProgress(TargetMC);
                > var Percentage:Number =
                > Math.round(Progress.bytesLoaded/Progress.bytesTotal*100);
                > _parent.loadingBar._xscale = Percentage;
                > _parent.percentNumber.text = Percentage+"%";
                > _parent.bytesDisplay.text = "loaded "+Progress.bytesLoaded+" of
                > "+Progress.bytesTotal+" bytes";
                > if (Progress.bytesLoaded == Progress.bytesTotal) {
                > clearInterval(loadingCall);
                > _parent.loadingBar._visible = false;
                > _parent.percentNumber._visible = false;
                > _parent.bytesDisplay._visible = false;
                > _parent.loadingFrame._visible = false;
                > }
                > }
                >
                > Thanks!
                >


                • 5. Re: Problems with preloader
                  Level 7

                  "Belleal" <webforumsuser@macromedia.com> wrote in message news:eacd1b$8h$1@forums.macromedia.com...
                  > You do have right, tralfaz, but even if I check for this possibility what could
                  > I do? If the bytes are not correct the preloader is still useles and I need to
                  > work around it somehow...

                  There are thousands of working preloaders available. There is absolutely no reason to design your own.
                  tralfaz