Is there a easy way to figure out consistently when a Dialog closes that has been created through PopUpManager. I would have suspected some type of message or callback mechanism, but there does not seem to be. In one case I use the WindowTitle component and event that only fires the CLOSE if someone presses the close and give no message when the dialog actually closes.
+1
A:
Not sure if this is the solution to all needs. But, if you're using a TitleWindow, just listen to the close event:
Something like this:
var win : IFlexDisplayObject = PopUpManager.createPopUp(Application.application as DisplayObject, TitleWindow, false) as IFlexDisplayObject;
win.addEventListener(CloseEvent.CLOSE, onClose);
PopUpManager.centerPopUp(win);
And the title window should be something like this:
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" showCloseButton="true" close="closeHandler(event)">
<mx:Script>
<![CDATA[
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
protected function closeHandler(event:CloseEvent):void
{
PopUpManager.removePopUp(this);
}
]]>
</mx:Script></mx:TitleWindow>
www.Flextras.com
2010-05-01 16:43:59
That is what I originally thought, but when I looked into it the CloseEvent only happens when you click the "X". The solution I implemented was to create a DialogBaseEvent class with APPLY and CANCEL events and fire those when user hits APPLY or CANCEL. I then use those events to trigger the close properly removing the event listeners I needed to remove. Not ideal, but in my case it will serve its purpose.
WeeJavaDude
2010-05-03 23:46:30