Flex addChild not working with Custom TitleWindow

blue44 used Ask the Experts™

I'm using a custom TitleWindow component that animates the opening and closing of a TitleWindow.  The code example and custom component, 'AnimatedTitleWindow', can be found on this guy's site: http://www.binarygiant.com/blog/?p=27

Everything compiles and runs correctly except that my child window, 'UserPopUp', is not being displayed in the TitleWindow (AnimatedTitleWindow).  

Any help would be greatly appreciated.

//main app 
private function doUserPopup():void{
		var fadeIn:Fade = new Fade();
		fadeIn.duration = 1000;
		fadeIn.alphaFrom = 0.0;
		fadeIn.alphaTo = 1.0;
		var fadeOut:Fade = new Fade();
		fadeOut.duration = 1000;
		var anTW:AnimatedTitleWindow = new AnimatedTitleWindow(fadeIn,fadeOut);
		anTW.title = "Case Ready Notification";
		anTW.styleName = "userPopUp";
		anTW.width = 300;
		anTW.height = 150;
		anTW.showCloseButton = true;
		var userPopUp:UserPopUp = new UserPopUp();
		PopUpManager.addPopUp(anTW,Application.application as DisplayObject);
//UserPopUp component
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
	<mx:HBox x="19" y="10">
		<mx:Label text="Your appointment with us has arrived."/>

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
zzynxSr. Software engineer

Maybe a stupid remark but did you already try the same code in which you replace AnimatedTitleWindow by TitleWindow?


Good thought.  I tried changing it to TitleWindow but same result.

var anTW:TitleWindow = new TitleWindow();

His code works so it's a real head scratcher!!
zzynxSr. Software engineer

>> I tried changing it to TitleWindow but same result.
Meaning that the problem isn't related to the use of that specific AnimatedTitleWindow

>> His code works so it's a real head scratcher!!
But does he use any addChild() call?


Yes, he uses the addChild() call.  I've attached the excerpt from his code.


             * @private the method that will set up the pop up (AnimatedTitleWinodw);
            private function animatePopUp():void
                //create an instance of the AnimatedPopUpWindow component
                var anTW:AnimatedTitleWindow = new AnimatedTitleWindow(this.openEffect,this.closeEffect);
                anTW.title = "Example"
                //set the properties of the AnimatedTitleWindow instance, e.g. the close button
                anTW.showCloseButton = true;
                //add the event listener for the CloseEvent.CLOSE so that the close event handler can handle the closing of the AnimatedTitleWindow
                //now create an instance of whichever component will be contained by the AnimatedTitleWindow
                var test:Test = new Test();
                //add the dummy component to the AnimatedTitleWindow
                //use the PopUpManager to add the AnimatedTitleWindow to the application as a pop up
                PopUpManager.addPopUp(anTW,Application.application as DisplayObject);

Open in new window

Well, it doesn't look like I could get that sample code to work so I went with a work-around demonstrated below.

Thanks to everyone for trying...:-)

<mx:Fade id="fadeOut" duration="1000" alphaFrom="1.0" alphaTo="0.0"/>
<mx:Fade id="fadeIn" duration="1000" alphaFrom="0.0" alphaTo="1.0"/>
private function doUserPopup():void{
	var titleWindowInstance:UserPopUp = UserPopUp(PopUpManager.createPopUp(this,UserPopUp,false)); 
	titleWindowInstance.title = "Case Ready Notification";
	titleWindowInstance.width = 300;
	titleWindowInstance.height = 160;
	fadeIn.target = titleWindowInstance;
/*****Custom Component*****/
private function closeWindow(event:CloseEvent):void{
	parentApplication.fadeOut.target = this;

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial