Search code examples
actionscript-3apache-flexflex4flex3

Set Popup Window Specific Position?


Actually in my Application Login Page is Popup..

private var login:Login;

        protected function loginPopUpHandler(event:MouseEvent):void
        {
            login = new Login();
            PopUpManager.addPopUp(login,this,true);
            PopUpManager.centerPopUp(login);
        }

Hear Popup coming Center .... But I want Popup Below the Button..

i.e... When we click the login Button Popup will open Below the Button..


Solution

  • First of all it depends what this is. If this for example is your Login button you can easily do like this:

    protected function loginPopUpHandler(event:MouseEvent):void
                {
                    login = new Login();
                    PopUpManager.addPopUp(login,this,true);
                    PopUpManager.centerPopUp(login);
                    login.x += loginButton.width / 2; // or any other number
                    login.y += 123; //whatever number. try tweaking it
                }
    

    If your want to use display object as FlexGlobals.topLevelApplication as DisplayObject then you probably want to get you login button from event.target and manipulate with its coordinates. Just try to experiment.
    Also you maybe will have to use localToGlobal property when playing with coordinates.