3 Replies Latest reply on Mar 29, 2011 10:25 PM by pgpradeep

    Absolute screen coordinates of an Flex object

    pgpradeep Level 1



      I want to calculate the absolute screen coordinates of an object in:


      1. Web Flex

      2. AIR Flex


      The co-ordinates should be absolute with reference to the monitor screen, i.e., object[x,y] should coincide with screen[x,y].

      Is there any way of procuring or calculating these co-ods?




        • 1. Re: Absolute screen coordinates of an Flex object
          The Flex Viking Level 1

          To convert a point relative to any object on your Flex form you want to use the localToGlobal method.  For example ..


          var p:Point = new Point(10,-15);    // define an offset

          var object.localToGlobal(p);          // converts the point object from the main Sprite coordinates (local) into the Stage coordinates (global).



          Well, I am trying to think about your requirement for the resolution of the monitor.  I am not sure why it is important to know monitor resolution vs application resolution.


          I haven't done much AIR so can't answer that, but since the Flex form is contained in the browser, the size of the Application will not be the resolution of the monitor.  My only guess as this point would be to write an ExternalInterface method in Flex that talks to the Browser, with the Browser perhaps returning it's size?



          • 2. Re: Absolute screen coordinates of an Flex object
            Flex harUI Adobe Employee

            In AIR, there should be enough info on NativeWindow.  In Web, you might need

            to see if there is JS that will return browser coordinates.

            1 person found this helpful
            • 3. Re: Absolute screen coordinates of an Flex object
              pgpradeep Level 1



              I want to take a screenshot of the AIR app, and then draw a border around a given component.

              For this, I can obtain the global position of the component(x,y,width,height).


              But when I draw the rectangle on the screenshot, the rectangle is offset by a y value equal to the titlebar height and an x value equal to the application border.


              I need to add these (titlebar height to y position and app border width to x position) to draw the proper border.


              So, my question is, how can I get the app border width and titlebar height of an AIR app.

              I looked at the NativeWindow property while debugging, but there is no info on these...