Troubleshooting PopUpManager.createPopUp
I have an intermittent bug where a custom titlewindow created by PopUpManager.createPopUp sometimes has trouble completing. It doesn't always happen, but it happens often enough that I suspect it has a predictable cause, I'm just not seeing what it is.
Here's the scenario:
A function calls PopUpManager.createPopUp with a custom TitleWindow.
According to trace, the custom TitleWindow is initialized, but doesn't reach "creationComplete" until PopUpManager.createPopUp is called again (say, by clicking on a button that opens a different pop-up).
What are the possible reasons PopUpManager might be unable to complete creation of a pop-up?
Here's the MXML for the pop-up. I've stripped it down to the bare bones and it still happens, so I suspect the problem lies elsewhere:
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="450" height="100%" close="close();" initialize="onInit();" creationComplete="onCreationComplete();" showCloseButton="false" styleName="helpDialog" horizontalScrollPolicy="off">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
private function onInit():void
{
trace("Initialized");
}
private function onCreationComplete():void
{
trace("Creation Complete");
this.y = 485 - this.height;
this.x = 15;
}
public function close():void
{
PopUpManager.removePopUp(this);
this.dispatchEvent(new Event("onClose"));
}
]]>
</mx:Script>
<mx:HBox id='missionContents' styleName='helpContents' width="95%">
</mx:HBox>
<mx:ControlBar paddingTop="5" paddingBottom="5">
<mx:Spacer width="100%"/><mx:Button label="OK" height="20" click="close();"/>
</mx:ControlBar>
</mx:TitleWindow>