2 Replies Latest reply on Jun 5, 2009 6:09 AM by AdamofKCD

    Loader Component Sequence Question

    AdamofKCD

      Hello!

       

      I have multiple "Loader Components" placed in a grid that are working great for loading external JPEG's.

       

      However, when I publish my file the "Loader Components" load each image randomly (I assume because they load the smallest file in size first then next largest and so on).

       

      How do I load the content of multiple "Loader Components" in a specific sequence?

       

      Here is the script I have so far:

       

      ////"Thumb1" is the instance name of the first "Loader Component" in the grid. Next is "Thumb2", then "Thumb3" and so on

       

       

      Thumb1.load()

      if (Thumb1.percentLoaded >= 1 ) {

      Thumb2.load();}

      if (Thumb2.percentLoaded >= 1) {

      Thumb3.load();}

      if (Thumb3.percentLoaded >= 1) {

      Thumb4.load();}

      if (Thumb4.percentLoaded >= 1) {

      Thumb5.load();}

       

       

      I would LOVE to figure out how to accomplish this in AS 2.0

       

      Cheers!

      Adam

        • 1. Re: Loader Component Sequence Question
          clbeech Level 3

          hmmm... it's hard to say without seeing the rest of your code structure, that is how you are loading the contents and monitoring the progress events.  I would say that what you may want to do here is load each instance in sequence by using a 'complete' handler for each instance, increment an index and load the next instance.  something like this:

           

          var loaderArray:Array = [Thumb1, Thumb2, Thumb3, Thumb4, Thumb5];

          var loaderIndex:Number = 0;

           

          var loadListener:Object = new Object();

          loadListener.complete = function(e:Object) {

              if(loaderIndex < loaderArray.length-1) {

                  loaderIndex++;

                  loaderArray[loaderIndex].load();

              }else{

                  trace('loading complete');

              }

          }

           

          for(var instance in loaderArray) {

              loaderArray[instance].addEventListener('complete', loadListener);

          }

           

          loaderArray[loaderIndex].load();

          • 2. Re: Loader Component Sequence Question
            AdamofKCD Level 1

            This is brilliant, thank you very much!

             

            Cheers,

            Adam