3 Replies Latest reply on Mar 5, 2007 5:36 PM by Newsgroup_User

    preloading math?

    Level 7
      I would like to test how much of my movie is loaded and do things at
      20%, 40%, and so forth. Right now I have the following, but it is not
      working quite yet.

      movieloader_mclListener.onLoadProgress = function(target:MovieClip,
      numBytesLoaded:Number, numBytesTotal:Number):Void {

      if(numBytesLoaded / numBytesTotal == 20){
      trace("just hit 20");
      loadBar_mc.tear01._alpha = 100;
      }
      }

      So this ifStatment is not working I think. How would I test for 20% loaded?

      Thanks for any help!
      Brian
        • 1. Re: preloading math?
          Level 7
          I guess that ifStatement should be more something like this:

          if((numBytesLoaded / numBytesTotal * 100) == 20){
          trace("just hit 20");
          loadBar_mc.tear01._alpha = 100;
          }

          But still not working. What is wrong?
          • 2. Re: preloading math?
            Level 7
            "Brian" <brian@agilitygraphics.com> wrote in message
            news:esifdf$cgf$1@forums.macromedia.com...
            >I would like to test how much of my movie is loaded and do things at 20%,
            >40%, and so forth. Right now I have the following, but it is not working
            >quite yet.

            > if(numBytesLoaded / numBytesTotal == 20){

            basic math problem .. you are seeing if the bytes loaded is exactly 20 times
            bigger than the total number of bytes !!

            > So this ifStatment is not working I think. How would I test for 20%
            > loaded?

            for a start, try

            if (numBytesLoaded / numBytesTotal >= 0.20) {


            • 3. Re: preloading math?
              Level 7
              Jecky,
              thank you, that works.

              Brian