Centering pop ups.

I’ve wrapped up a project with Jeff (great guy to work with!) WIthout giving anything away, part of my task was some forms for the app. IE. mail this thing to my friend, request information, that kind of thing, well actually those two things almost exactly :)

The PopUpManager, is a darn cool class. This was my first time using it and it was cake.

A few lines and you’ve got yourself a popup. What we ran into was the popup seems to want to appear in the upper left of the app. No problem, use PopUpManager.centerPopUp(popup).

That’s great if your main application is the parent of the popup, since centerPopUp() centers over the parent. in our case, that a component in the upper left also.

Solution, Found thanks to FlexCoders, set your popup’s parent to Application.application.

var myParent:DisplayObject = Application.application as DisplayObject;
var myPopUp:formComponent = MailToFriendForm(PopUpManager.createPopUp(myParent, formComponent, true));

Now our main stage (the entire swf) is the parent of the popup, so centering works perfectly.


2 thoughts on “Centering pop ups.

Comments are closed.