4 Replies Latest reply on Feb 20, 2007 6:10 PM by SPGAnne

    preloader problem - feel like an idiot

    SPGAnne Level 1
      I feel like a total idiot. I can't seem to get my preloader to work. Here's my code. What am I doing wrong? The problem is that myApp.swf loads successfully but the .onEnterFrame function thinks that loader_mc is 1 frame and 0 bytes long.
        • 1. Re: preloader problem - feel like an idiot
          Rothrock Level 5
          Well sometimes it takes a moment to get proper numbers for the getBytesLoaded/Total. They can also for a moment jump to something like -1 or -4 (I can't remember exactly which!) So…

          percentage= Math.round(-1/-1*100);

          will give, tada, 100. The easy solution is:

          if(percentage >=99 && kBytesLoaded > 0)
          • 2. Re: preloader problem - feel like an idiot
            SPGAnne Level 1
            wow. Thank you VERY much. I spent many hours banging my head against the wall on this one, feeling too embarassed to post. Should have done so sooner. It would've saved me a lot of time. Thanks again!
            • 3. Re: preloader problem - feel like an idiot
              Rothrock Level 5
              Glad that worked out for you.

              Remember that Flash does what you tell it, not what you want. So to diagnose these things for yourself you need to assume that is the case.

              In this case if the conditional was evaluating you must have been getting the percentage as bigger than 99 and since you were using Math.round it must have been 100.

              The next question would then be, "What else can equal 100%?" And from there you would of course have wanted to see what values you were getting for the getBytesLoaded/Total.

              Of course sometimes it is hard to see the forest for the trees, but just take whatever conclusions you can make to their extreme and test them out!
              • 4. Re: preloader problem - feel like an idiot
                SPGAnne Level 1
                Again, I much appreciate your help. I had put some trace statements in trying to find out what getBytesLoaded/Total were and they were coming back with values I didn't understand, so I kept thinking it was trying to get the values of the empty_mc I had instantiated instead of the thing I was trying to load and I kept scratching my head as to why and tried a lot of different things and was baffled. At any rate, in the end I think it's a timing issue if I understand correctly. In other words, I think the function started executing before it could really grab the correct information about the .swf that I was trying to load. Is that right?

                Oh well, I'm out of the ditch with that silly problem now and moving on to my next set of challenges. :-)

                Again, thank you so VERY much for being a willing helping hand to us newbies out here.