Here is a way to show effects for your pop-up window when it loads and unloads. I was trying to create a pop-up notification window, same as what you can see when you go full-screen from a flash/flex application (”Press Esc to exit full screen mode”).
Here is the code for the MXML component which will be used as the PopUp window. I am extending a Canvas for this component.
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
cornerRadius="8"
borderStyle="solid"
borderColor="#000000"
backgroundColor="#000000"
backgroundAlpha="0.85"
>
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
private var _title:String;
private var rt:Timer;
[Bindable]
public function get title():String
{
return _title;
}
public function set title(val:String):void
{
_title = val;
rt = new Timer(1500);
rt.addEventListener(TimerEvent.TIMER,timerHandler);
rt.start();
fadeEff.end();
fadeEff.play();
}
private function timerHandler(e:TimerEvent):void
{
fadeRem.end();
fadeRem.play();
rt.removeEventListener(TimerEvent.TIMER,timerHandler);
rt=null;
}
private function effectEndHandler():void
{
_title = null;
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
<mx:Text id="txt"
selectable="false"
width="90%"
text="{title}"
textAlign="center"
styleName="notifierFontStyle"
blendMode="{BlendMode.INVERT}"
/>
<mx:Fade id="fadeEff"
alphaTo="1"
duration="800"
target="{this}"/>
<mx:Fade id="fadeRem"
alphaTo="0"
duration="800"
target="{this}"
effectEnd="effectEndHandler()"/>
</mx:Canvas>
Open this with PopUpManager class as below:
var pop:Notifier = Notifier(PopUpManager.createPopUp(Notifier)); // Caste the IFlexDisplayObject object returned by createPopUp into ‘Notifier’ type and assign to a pop variable.
pop.width = stage.width-30; setting up some width relative to the stage.
pop.title = “Hope this help someone” // I have getter/setter ‘title’ in Notifier class. Assign the message there. This is how you pass values to a pop-up window in flex.
PopUpManager.centrePopUp(pop); // Centre your pop up window relative to the stage.
Here you go. Hope this helps someone.