4 Replies Latest reply on Sep 24, 2010 1:26 PM by SpiritOfTheWinds

    Loader (Need help to convert from AS3 to AS2)

    SpiritOfTheWinds

      Since I know this code works fine and that I use it into one of my AS3 flash, I need it in one of my AS2 flash and I don't know how to adapt it. I've searched in over 100 threads and I can't find something similar... Thanks to help me get it to work in AS2! Since I need it in AS2, I thought it would be the right place to post it.

       

      I posted all the loading process code, but I would need help mostly with the Loader part. How to do it in AS2? Thanks!

       

      var img = 0;
      var image_total = 0;

      var myImages_array:Array = new Array();
      var myBitmaps_array:Array = new Array();

       

      function Init();

      {

      // Images urls are loaded into an array before this call
      LoadImage();

      }


      function LoadImage()
      {
          if (img < myImages_array.length) // img is the current image index and myImages_array is my array of URLs
          {

      // I need help with this part please
              var loader:Loader = new Loader();

      // returns the image full path and load it
              loader.load(new URLRequest(my_site_url + myImages_array[img]));
              loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);

          }
          else
          {
              if (count == 0)
              {

      // When everything's loaded, I'll start loading my Bitmaps into a small slideshow
                  count += 1;
                  init_slideshow();
              }
          }
      }

       

      function imageLoaded(e:Event):void
      {
          var image:Bitmap = e.target.content;

       

      // Bitmap manipulation here (removed)
         
          image_total = myBitmaps_array.push(image);
         
          if (img < myImages_array.length)
          {
              img += 1;

      // Call next image
              LoadImage();
          }
      }

       

      function init_slideshow():void
      {

      // Reserts the current index for the first one
          img = 0;

      // Start the slideshow since everything's loaded
          animate_slideshow();
      }