title: Synchronous dialogs in Flex?
body: <p>How can I open a synchronous dialog in Flex? I need to call a function from an External Interface (JavaScript) that will open a simple dialog in the Flex application and returns an value according to the button the user has clicked (OK/Cancel).</p>
  
  <p>So it should by a synchronous call to a dialog, i.e. the call waits until the user has closed the dialog like this.</p>
  
  <pre><code>//This function is called by JavaScript
  function onApplicationUnload():Boolean
  {
    var result:Boolean;
    result = showDialogAndWaitForResult();
    return result
  }
  </code></pre>
  
  <p>Does anybody know how I can do this? I could write a loop that waits until the dialog has set a flag and then reads the result to return it, but there must be something that is way more elegant and reusable for waiting of the completion of other asynchronous calls.</p>
  
  <p><strong>EDIT:</strong>
  Unfortunately a callback does not work as the JavaScript function that calls onApplicationUnload() itself has to return a value (similar to the onApplicationUnload() function in Flex). This JavaScript function has a fixed signature as it is called by a framework and I cannot change it. Or in other words: The call from JavaScript to Flex must also be synchronous.</p>