Apache flex 从弹出窗口内部调用PopUpManager.removePopUp()时,模式窗口动画中断
我有一个模式窗口,在打开和关闭时显示一个调整大小的动画,但有时在关闭时会闪烁 我找到了一件事。当我在窗口外单击时,关闭动画将正常播放。代码位于主应用程序中,位于mouseUpOutsideHandler方法中。这是对PopUpManager.removePopUp的简单调用。当我单击窗口内的close按钮时,它在窗口内的close方法中运行相同的代码PopUpManager.removePopUp,只是它先闪烁 除了在模态窗口实例中调用之外,它是完全相同的代码。看起来模态窗口正在淡出,然后被删除,然后播放“我的删除”动画。参见代码示例 例如:Apache flex 从弹出窗口内部调用PopUpManager.removePopUp()时,模式窗口动画中断,apache-flex,flex-spark,Apache Flex,Flex Spark,我有一个模式窗口,在打开和关闭时显示一个调整大小的动画,但有时在关闭时会闪烁 我找到了一件事。当我在窗口外单击时,关闭动画将正常播放。代码位于主应用程序中,位于mouseUpOutsideHandler方法中。这是对PopUpManager.removePopUp的简单调用。当我单击窗口内的close按钮时,它在窗口内的close方法中运行相同的代码PopUpManager.removePopUp,只是它先闪烁 除了在模态窗口实例中调用之外,它是完全相同的代码。看起来模态窗口正在淡出,然后被删除
可以稍后使用call进行修复 方法1
protected function close():void {
//PopUpManager.removePopUp(this);
callLater(PopUpManager.removePopUp, [this]);
}
方法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
}
}
奖金代码
// 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);
}
}
}
此外,您还可以查看effects类是否适合您 手动调用隐藏/删除效果并侦听完整事件如何。然后在完整处理程序中删除弹出窗口。
// 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);
}
}
}