3 Replies Latest reply on Oct 22, 2010 1:49 PM by Daniel Rinehart

    Waiting for multiple independent asynchronous events during startup

    Daniel Rinehart Level 1

      I recently found myself needing to load two external files during the setup phase of a test. Normally I'd use Async.proceedOnEvent() with something like:

       

              [BeforeClass(async)]

              public static function setUpBeforeClass():void

              {

                  _oneRecord = new URLLoader(new URLRequest("data/OneRecord.csv"));

                  Async.proceedOnEvent(ZeoCSVParserTest, _oneRecord, Event.COMPLETE);

                  // Trying to load the second file causes problems

                  // _complexRecord = new URLLoader(new URLRequest("data/ComplexRecord.csv"));

                  // Async.proceedOnEvent(ZeoCSVParserTest, _complexRecord, Event.COMPLETE);

              }

       

      In this case adding a second Async.proceedOnEvent() doesn't work. I ended up creating an event aggregator class to handle waiting for the needed events. I was curious if there was a facility already built in that would handle this?