It can be fixed by using call later.
METHOD 1
protected function close():void {
//PopUpManager.removePopUp(this);
callLater(PopUpManager.removePopUp, [this]);
}
METHOD 2
function close(popUp:IFlexDisplayObject, endEffectsPlaying:Boolean = true) {
if (popUp && popUp as IUIComponent && UIComponent(popUp).isEffectStarted) {
if (endEffectsPlaying && popUp && popUp as IUIComponent) {
EffectManager.endEffectsForTarget(popUp as IUIComponent);
}
// we exit out because if we continue, we would close the pop up.
// but if we did that then when the effect ends it puts up a
// display object "shield" and there would be no way to close
// the display object shield since we removed the pop up
// display object that has our closing event listeners
return;
}
try {
PopUpManager.removePopUp(popUp as IFlexDisplayObject);
}
catch (error:Error) {
// sometimes the pop up is already closed or something
// or there's a bug in PopUpManager or EffectManager
}
}
BONUS CODE
// The following code may be unrelated but it was
// in my pop up so it might be helping prevent an error
// i normally don't add unrelated code but it may help
protected function panel1_resizeHandler(event:ResizeEvent):void {
if (stage && !addedEffect.isPlaying) {
// to fix bug on line 505 of PopUpManagerImpl
var popUpImp:PopUpManagerImpl = PopUpManagerImpl(Singleton.getInstance("mx.managers::IPopUpManager"));
var popupInfo:Array = popUpImp.popupInfo;
const n:int = popupInfo.length;
var instanceIndex:int = -1;
for (var i:int = 0; i < n; i++) {
var o:PopUpData = popupInfo[i];
if (o.owner == this) {
instanceIndex = i;
}
}
if (instanceIndex!=-1) {
PopUpManager.centerPopUp(this);
}
}
}
Also, you can see if the OpenPopUp and ClosePopUp effects class works for you.