0 Replies Latest reply on Jun 17, 2009 5:51 AM by EverLightMusic

    preloading folders of content with PreloadAssetManager?

    EverLightMusic

      I'm currently using the following code to preload images into the browsers cache:

       

      import gs.dataTransfer.PreloadAssetManager;

       

      var preloader_obj = new PreloadAssetManager(["images/SS001small.jpg","images/sticker.jpg"], onFinish);

       

      this.onEnterFrame = function() { //Just to update the preload status bar
          preloader_mc.bar_mc._xscale = preloader_obj.percentLoaded_num;
          preloader_mc.percent_tf.text = Math.round(preloader_obj.percentLoaded_num) + "%";
      }

       

      function onFinish(pl_obj:PreloadAssetManager):Void { //Gets called when all the assets are preloaded.
          trace("Finished preloading all " + pl_obj.assets_array.length + " assets!");
          var a = pl_obj.assets_array;
          for (var i = 0; i < a.length; i++) {
              trace("--Asset: " + a[i].url_str + " had a width of: " + a[i].width + ", a height of: "+a[i].height);
              if (a[i].fileType_str == "flv") {
                  trace("FLV duration: "+a[i].duration);
              }
          }
          _root.onEnterFrame = null;
          gotoAndPlay("start");
      }

       

      stop();

       

      these images are embedded using <img> tags in .xml files to make the website easy to update. At the moment everything works great, but the problem is that the code I have for my preloader requires you to list all of the images seperatly, which defeats the purpose of updating the content via XML. (Obviously, if you add any more images to the folder, you will need to edit the main website file to update the preloader)

       

      Is there a way I can somehow tell this code to load all images inside the /images folder instead of listing the images seperatly?