johnwilker.com

Centering pop ups.

Posted on | March 29, 2007 | 2 Comments

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.

 

Comments

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

2 Responses to “Centering pop ups.”

  1. nerdabilly
    September 25th, 2007 @ 12:00 am

    Thanks SO much! This is exactly what I’ve been looking for for the last 2 days!

  2. nerdabilly
    January 7th, 2009 @ 2:45 am

    Thanks SO much! This is exactly what I've been looking for for the last 2 days!

Leave a Reply