We are trying to migrate an application written in a
procedural language (=not based on events) to Flex and
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;
//Inside this Window the WindowOpen variable is set to false
when the window is closed
//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 ?
You cannot suspend execution of the Flash Player or it will
hang as you have seen. You are kind of butting heads with the two
paradigms. Our "modal" pop-up simply means that the user cannot
interact with the rest of the application, but it does indeed
continue to run (this allows the Flash Player to update the display
should you drag the dialog box around, or allow data to be received
from remote services, etc.).
You may not have a big re-write here. Try something like
popup the dialog();
... code continues
NEW CODE popup the dialog();
add event listener for "close" event on the popup
exit the function
in the "close" event handler, execute the "code continues"
part now that the dialog has been closed.