我有一个模式窗口,我正在显示一个调整大小的动画打开和关闭,但有时它闪烁关闭。
我追踪到一件事。当我点击窗口外,关闭动画播放良好。代码在主应用程序中,在mouseUpOutsideHandler
方法中。这是对PopUpManager.removePopUp()
的简单调用。当我单击窗口内的“关闭”按钮时,它在窗口内的close()
方法中运行相同的代码close()
,除非它首先闪烁。
这是完全相同的代码,只是它是从模态窗口实例中调用的。它看起来像模式窗口是褪色,然后删除,然后我的删除动画播放。参见代码示例。
示例:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import com.flexcapacitor.effects.popup.OpenPopUp;
import mx.core.IFlexDisplayObject;
import mx.managers.PopUpManager;
protected function showPopUp():void {
var myPopUp:MyPopUp = new MyPopUp();
PopUpManager.addPopUp(myPopUp as IFlexDisplayObject, this, true);
PopUpManager.centerPopUp(myPopUp);
myPopUp.addEventListener(OpenPopUp.MOUSE_DOWN_OUTSIDE, mouseUpOutsideHandler, false, 0, true);
}
private function mouseUpOutsideHandler(event:Event):void {
// does not create a flicker
PopUpManager.removePopUp(event.currentTarget as IFlexDisplayObject);
MyPopUp(event.currentTarget).removeEventListener(OpenPopUp.MOUSE_DOWN_OUTSIDE, mouseUpOutsideHandler);
}
]]>
</fx:Script>
<fx:Declarations>
<fx:Component className="MyPopUp">
<s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
resizeEffect="Resize"
resize="panel1_resizeHandler(event)"
creationCompleteEffect="{addedEffect}"
removedEffect="{removedEffect}"
width="400" height="200">
<fx:Script>
<![CDATA[
import mx.events.ResizeEvent;
import mx.managers.PopUpManager;
protected function close():void {
// when called here creates a flicker effect
// it looks like the pop up is faded out and removed
// and then the removed effect is played
PopUpManager.removePopUp(this);
}
protected function panel1_resizeHandler(event:ResizeEvent):void {
if (stage && !addedEffect.isPlaying) {
PopUpManager.centerPopUp(this);
}
}
]]>
</fx:Script>
<fx:Declarations>
<s:Parallel id="removedEffect" target="{this}" >
<s:Scale3D scaleYTo="0" duration="1000" startDelay="0" disableLayout="false"
autoCenterProjection="true" autoCenterTransform="true"/>
<s:Fade alphaFrom="1" alphaTo="0" duration="500" startDelay="50"/>
</s:Parallel>
<s:Parallel id="addedEffect" target="{this}" >
<s:Scale3D scaleYFrom="0" scaleYTo="1" duration="250" disableLayout="false"
autoCenterProjection="true" autoCenterTransform="true"/>
<s:Fade alphaFrom="0" alphaTo="1" duration="200"/>
</s:Parallel>
</fx:Declarations>
<s:Label horizontalCenter="0" verticalCenter="0" text="Hello World"/>
<s:Button horizontalCenter="0" verticalCenter="30" label="Close" click="close()"/>
</s:Panel>
</fx:Component>
</fx:Declarations>
<s:Button label="Show Pop Up"
horizontalCenter="0" verticalCenter="0"
click="showPopUp()"
/>
https://stackoverflow.com/questions/21113068
复制相似问题