1 Reply Latest reply on Aug 17, 2006 7:28 AM by inlineblue

    Suspend execution till an event is triggered ?

    Oh_Mitch_!
      Hello all,

      We are trying to migrate an application written in a procedural language (=not based on events) to Flex and ActionScript.
      For the moment everything is OK, except an issue we have which may force us to rewrite the biggest part of the app :

      In our current version of the application, the code looks like this :
      ==========
      MyCustomer = OpenWindow("SelCust")
      ProcessOrder("MyCustomer") //Inside this function, a Window is opened and closed
      ==========

      With Flex & AS3, we use the PopupManager class to open a Modal Window. The problem is that the code continues to execute without waiting for the window to be closed... So we are looking for a way to suspend the execution of our code. We tryied to use a global variable like this :
      ==========
      WindowOpen = true;
      mx.managers.PopUpManager.createPopUp(CurWin, TitleWindow, true, obj); //Inside this Window the WindowOpen variable is set to false when the window is closed

      while (WindowOpen)
      {
      //Wait till the Window is closed
      }
      ... code continues
      ==========
      The problem is that the application hangs in the While() loop and we have to kill the process :-(

      So here are our questions :
      - Is there a way to suspend the execution of a as3 code till an event is triggered ?
      - Is there a call we could do in the While() loop to avoid the hang of the app (like Windows' message queue functions) ?
      - Would someone have an idea that would allow us to convert our current procedural code into Flex&AS3 without rewriting the hundreds of procedures in "event" mode ?

      Thank you in advance for your help and advices.

      MiF
      PS : Please forgive my bad english :-(