4 Replies Latest reply on Sep 10, 2006 1:24 PM by Sabbathacker

    Preloader

    Sabbathacker Level 1
      Ok, so as you can guess, my preloader isn't quite right. It works, and sometimes to is way less than 100% when site is completed loading. Sometimes its goes to 100%, but the 100 frame animation (to match 100%) loops more than once. The code I'm using was found here (Somewhere). Sorry I can't post it, I'm at work with no access to the fla.

      Any ideas what would cause this? Also any advice on the site in general is always welcome.

      Heres the site:
      www.soundwerx.net
        • 1. Re: Preloader
          Level 7
          Sabbathacker,

          > Ok, so as you can guess, my preloader isn't quite
          > right.

          I hadn't guessed.

          > It works, and sometimes to is way less than 100%
          > when site is completed loading.

          So then it doesn't work, right? ;)

          > Sometimes its goes to 100%, but the 100 frame
          > animation (to match 100%) loops more than once.
          > The code I'm using was found here (Somewhere).

          > Any ideas what would cause this?

          Heh, you haven't posted the code! It could be anything. This is the
          blessing and the curse of code samples: people use them -- they say, "I
          have this code," or "I used this code" -- but they often have no idea how
          the code works. When the sample fails, as copied/pasted into an actual
          project, they're stuck.

          Do you understand the principles behind the code you found? Can you
          find that URL?


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Preloader
            Sabbathacker Level 1
            I guess I don't know your personality very well, but I can feel the sarcasim. ;)
            Yes, I fully understand the code and all things Flash. I frequently post in forums, asking questions that I fully know the answers to...

            No, I don't know much about AS. I happened to find some code that seemed very simple to use. (And it was) I thought I would add it to my site. My site was taking a while to load. (due to a mp3 file) I thought it might be nice to show the visitors what is going on. So... I used the following code. Like I said, it seems to do what its suppose to. It shows the percent downloaded. It moves through the MC frame by frame as it should. Sometimes it goes to 100% and all frames shown. Sometimes its only at 50% completion, yet the MC is at the end. Other times, its at 100% and the MC is only about half way done.

            stop();
            this.onEnterFrame = function () {
            bl = this.getBytesLoaded();
            bt = this.getBytesTotal();
            if (bt <= 0) {bt = 99;}
            offPreloader.gotoAndStop(Math.floor((bl / bt) * 100));
            preload_txt.text = Math.round((bl / bt) * 100) + " %";
            if ((bl == bt) && (bt > 0)) {
            delete this.onEnterFrame;
            gotoAndPlay (3);

            }
            };

            From THIS post...

            I did change it to match my project. The MC and AS are in one scene. I have the "gotoandplay" pointed to the main scene.

            Thanks!!
            • 3. Re: Preloader
              Level 7
              Sabbathacker,

              > I guess I don't know your personality very well, but I
              > can feel the sarcasim. ;)

              I assure you, what sounds like sarcasm (from me, anyway) is perhaps 50%
              actual sarcasm and 50% honest-to-goodness nudging in what I hope is a
              beneficial direction. And even the 50% sarcasm isn't meant to drive you (or
              anyone away) -- only to keep things lighthearted.

              > Yes, I fully understand the code and all things Flash.

              In light of our discussion so far, how do you expect me to react to this
              statement?

              > I frequently post in forums, asking questions that I
              > fully know the answers to...

              I guess you're being sarcastic now. :-p

              > No, I don't know much about AS. I happen to find
              > some code that seemed very simple to use.

              Fair enough. I'm not knocking you. What I asked was whether you
              understood the *principles* behind the code you found. I made a general
              comment on the notion that so many people find code but aren't able to use
              it. That's a frustrating experience for many people. I generally find it's
              easier for people when they understand general principles first, then build
              on that understanding with specific syntax to achieve a specific goal.

              > (And it was)

              But it wasn't easy to use -- because you're having trouble, right? (No
              sarcasm, I swear. Just trying to understand you.

              > stop();

              This line stops the timeline it's in.

              > this.onEnterFrame = function () {

              This assigns a function to the MovieClip.onEnterFrame event of the
              timeline (of the movie clip) it's in -- presumably the main timeline.

              > bl = this.getBytesLoaded();
              > bt = this.getBytesTotal();

              This sets two arbitrarily named variables, bl and bt, to the return
              values of MovieClip.getBytesLoaded() and MovieClip.getBytesTotal(),
              respectively, of the object this function is scoped to; namely (presumably)
              the main timeline.

              > if (bt <= 0) {bt = 99;}

              This sets the value of bt to 99 if it is less than or equal to zero. I
              don't think this would ever actually occur -- after all, the bytes total of
              a SWF is presumably always *greater* than zero, right? -- so this line might
              be something you could just drop.

              > offPreloader.gotoAndStop(Math.floor((bl / bt) * 100));

              This line tells a movie clip whose instance name is offPreloader to goto
              a certain frame and stop there. The decision on which frame is determined
              by the floored rounding (rounding down to nearest integer) of bl divided by
              bt, multiplied by 100.

              > preload_txt.text = Math.round((bl / bt) * 100) + " %";

              This sets the text of a text field whose instance name is preload_txt to
              the same number.

              > if ((bl == bt) && (bt > 0)) {

              This if() statement checks if the value of bl and bt are equal AND if
              the value of bt is greater than zero.

              > delete this.onEnterFrame;
              > gotoAndPlay (3);

              If so, the onEnterFrame event handler is cancelled and the timeline is
              told to go to frame 3 and play.

              Knowing the above, does that clarify anything for you? (Again, no
              sarcasm. Trying to help.)


              David Stiller
              Adobe Community Expert
              Dev blog, http://www.quip.net/blog/
              "Luck is the residue of good design."


              • 4. Re: Preloader
                Sabbathacker Level 1
                No worries, my second language is sarcasm. ;) It will take much more than that to scare me off.

                I have programmed before, so I do understand the basics. AS is new to me, so parts of the code make sense, other parts don’t.

                I really appreciate the time you’ve taken to explain the code to me. The code does make a lot more sense. I’m still not sure what is happening on my site, but I will do some trial and error.

                Thanks again!!