1 Reply Latest reply on Jan 31, 2007 12:08 AM by KnowRama

    preloader: can I define a custom location?

    SuperRoach
      Gidday,

      Like most people writing a preloader, the basis of it is getting the total bytes and bytes loaded so you can get a percentage, and know when to remove the loader.
      So far I have a function which finds which button has been clicked, and starts the preloader. All of the content is loaded in to layer1 , however in the future it could be loaded anywhere.

      So, running through the code I have, The function is called by a
      onEnterFrame = preloadContainer();


      and the code it calls....

      inside function preloadContainer() :
      var bytes_loaded = _level1.getBytesLoaded();
      var bytes_total = _level1.getBytesTotal();

      ... bunch of code to load the thing

      if (bytes_total > 0){
      ... put the percentage values in text boxes and do any other math
      if (percent_loaded == 100){
      ... hide the logo
      delete onEnterFrame;
      // --^ This is to stop the enterframe checking of how much of the loading is done
      }

      This all works fine and good, but the location is static. I thought that calling it differently might help...
      onEnterFrame = preloadContainer("_level1");



      and inside the preloadContainer(preloadLocation) :
      var bytes_loaded = eval(preloadLocation).getBytesLoaded();
      var bytes_total = eval(preloadLocation).getBytesTotal();


      The new code above only appears to check once, and not be an onenterframe type code, as when I click on a button, it will grab the last percentage, and act based on that. It won't updated as the newer movie clip is loaded...

      A bit annoying and complex, but its got me confused!