0 Replies Latest reply on Mar 10, 2010 3:06 PM by UbuntuPenguin

    FlexUnit Farce AddAsync

    UbuntuPenguin Level 4

      TL;DR FlexUnit Asyncs are not being called when chained even though the listener functions do get called.

      Hello Everyone ,

        I am running flex unit and I am running into a problem chaining async events.  Take for example the following code.  The first async function will fire.

      However , the second async doesn't fire.  But the listener function ( non-async ) that is set to listen for the second event does get called , My question is ,  how do I properly chain events.

      public function testMe():void

      {

           ...

           someDispatcher.addEventListener( SomeDispatcherEvent.SomeEvent , addAsync( firstAsync , 2000 ) );

           someDispatcher.dispatchEvent( new Event(SomeEvent) );

          ....

      }

       

      public function firstAsync(  event:SomeEvent ):void

      {

           someDispatcher.increment++;

           someDispatcher.addEventListener( SomeDispatcherEvent.SomeEvent_2 , addAsync( secondAsync, 2000 ) );

           someDispatcher.dispatchEvent( new Event(SomeEvent) );

      }

       

      public function listenerFunction(  event:... ):void

      {    

           var i:int = 10032;

      }

       

      public function secondAsync(  event:... ):void

      {

           someDispatcher.decrement++;

           someDispatcher.addEventListener( SomeDispatcherEvent.SomeEvent , addAsync( secondAsync, 2000 ) );

           someDispatcher.dispatchEvent( new Event(SomeEvent) );

      }