Flex and popups

21 01 2008

Oh the joy.

I’ve been implementing the PopUpManager to bring me customised popups. The cool thing is, it can very easily load up a separate MXML application within the popup, thereby compartmentalising the code beautifully.

For example: here’s my popup file, called Popup.as

<?xml version=”1.0″ encoding=”utf-8″?>

<mx:TitleWindow xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute>



public function functionAvail():void





<mx:Canvas y=”21” width=”554” height=”459horizontalCenter=”0>



And here’s the implementation: main.mxml

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute>



//todo: import your Popup class here if it is inside a separate package

private var _window:Popup = null;

private function goItemClick(event:ListEvent):void


_window = Popup(PopUpManager.createPopUp(this, Popup));

_window.showCloseButton = true;

_window.addEventListener(CloseEvent.CLOSE, closeHandler);

//functionAvail() is exposed via the new _window object (_window.functionAvail())


_window.title = “Viewer”;

//_centre the popup

_window.x = this.parent.width / 2 – _window.width;

_window.y = this.parent.height / 2 – _window.height / 2;


private function closeHandler(event:CloseEvent):void {








Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: