5 Replies Latest reply on May 5, 2009 6:05 PM by Flex harUI

    popup postioning question

    Bob in SC Level 1

      i'm trying to figure something out -- i want to position a popup window relative to its parent. However i always get parent.x resulting in 0 (x and y). To test this i created nested windows (parent calls "large", "large" call medium an medium calls small). each does an alert showing this.x and parent.x. what am i missing?

       

      also...how would i reference a parent's parent window? <-- yes i know this is a really basic question.

        • 1. Re: popup postioning question
          Flex harUI Adobe Employee

          Well, with popups, there aren't any basic questions...

           

          Popups are parented by SystemManager which may not be what you expected, and are thus in a different coordinate space.  Use of localToGlobal and globalToLocal is probably needed in this case.  Might be better if you show code snippets if you're still stuck.

           

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: popup postioning question
            Bob in SC Level 1

            thanks...yes i now see that all pop ups are parented by system manager so this kind of explains why parent.x = 0; however the documentation seems to indicate that the object that you specify as the 'parent' can be used for positioning.

             

            parent:DisplayObject — DisplayObject to be used for determining which SystemManager's layers to use and optionally the reference point for centering the new top level window. It may not be the actual parent of the popup as all popups are parented by the SystemManager.

             

            So if this displayobject's position isn't what's returned when i request parent.x...is there another way to reference it so that i can determine its location?

             

            BTW...here's a couple code pieces -- this is one popup calling another.

            • 3. Re: popup postioning question
              Flex harUI Adobe Employee

              The PopUpManager remembers which parent you passed in and will use it as a default when centering.  Since you passed that parent in, you already have a reference to it, and should be able to use it right after addPopUp.

               

              If you want to get it from the context of the new PopUp, you'll probably need your own mechanism for keeping track.

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

              Blog: http://blogs.adobe.com/aharui

              • 4. Re: popup postioning question
                Bob in SC Level 1

                OK, then i'm confused as to why when the parent does a this.x he gets 400 (his true x position) and when the child (the popup) does a parent.x he gets zero instead of 400? I don't think it's any kind of relative coordinate system as if i do a move to 0,0 the child will go to absolute 0,0 in the browser.

                 

                so is there any way for the child/popup to determine the parent's position? I don't see how.

                • 5. Re: popup postioning question
                  Flex harUI Adobe Employee

                  We often set the popup's owner property to refer to the "parent".  The true parent of the popup is the SystemManager.  Compare the actual objects you are querying and you should see they are not the same.

                   

                  So for some parent component "foo" and popup "bar"

                   

                  PopUpManager.addPopUp(bar, foo, ...)

                  bar.owner = foo;

                   

                  from bar you can then do:

                   

                  trace(owner, owner.x);

                  and compare to:

                  trace(parent, parent.x);

                   

                   

                  Alex Harui

                  Flex SDK Developer

                  Adobe Systems Inc.

                  Blog: http://blogs.adobe.com/aharui