Macromedia Flex Macromedia Flex
Position popup when app is resized
  Home

Jul 06, 2007 - Position popup when app is resized
PopUp maintains position at right of screen as the application is resized

The title says it all.  Note the check for the existence of the pop-up in the resize handler.

Tracy

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="vertical"
    creationComplete="initApp()"
    resize="onResize(event)">
<mx:Script><![CDATA[
 import mx.managers.PopUpManager;
 import mx.containers.Panel;

  private var _popup:Panel;

  /** Runs on creationComplete */
  private function initApp():void
 {
  _popup = Panel(PopUpManager.createPopUp(this,
                                Panel,
                                true));  //instantiate and show the popup
  _popup.width = 250;                                    //set some properties
  _popup.height = 80;
  _popup.title = "Resize App to test";
  _popup.x = this.width - 260;
 
 }//initApp
 
 /** Runs on application resize event */
 private function onResize(oEvent:Event):void
 {
   if (_popup) {                                        //test for existence of popup
     _popup.x =  this.width - 260;                      //re-position the popup
   }
 }//onResize
]]></mx:Script> 
</mx:Application>

File Details
Created On Jul, 06, 2007 by Tracy Spratt
Last Modified On Jul, 06, 2007 by Tracy Spratt
Group: Tips and Articles
Flex Versions: 2.0
Category: General
Type: Complete Lesson
Difficulty: Beginner
Keywords:
Comments (1)
July 11, 2007 01:57PM - Jason Fillman
What about resizing the popup window? If I add the following to the onResize function: _popup.width = parent.width * .7; the window width is size correctly, but the contents of the popup are not resized properly. What happens is that the right side of the popup is cut off. How can I accomplish this?

You must be logged in to post.