Don’t center popups

When placing popups, the Flex PopupManager class gives a great method called centerPopup. But please, don’t use that. Rarely do you actually want a popup centered. It’s often times much more visually pleasing to above there.  I like placing the top of the popup around 20% of the height of the application.

A centered popup:

A popup at 20% from the top:


Of course this isn’t a hard-set rule.  Sometimes you want your popup in other locations.  For instance, if it was triggered by a toolbar at the bottom of your application it makes no sense to force the user to mouse that far up.
Here’s a quick method to place that popup, I register my main application component on startup, but you could easily pass that in or use a stage reference instead.  This method won’t work well if you popup is too tall.

 public class PopupPositioner {  public static var mainApp:UIComponent;

  public static function centerPopUp(popup:UIComponent) : void  {   popup.x = mainApp.width / 2 - popup.width / 2;   popup.y = mainApp.height / 5;  } }

1 Response to “Don’t center popups”


  • “I register my main application component on startup, but you could easily pass that in or use a stage reference instead.”

    Please explain what you mean by that sentence.

Comments are currently closed.