I believe to find the global position of myButton, call myButton.localToGlobal(new Point(0,0));
-Josh On Feb 8, 2008 11:53 AM, luvfotography <[EMAIL PROTECTED]> wrote: > Hi, try looking at the localToGlobal method: > Converts a Point object from the local coordinate system to the > global coordinate system. > > > --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, > "derelkington" > > <[EMAIL PROTECTED]> wrote: > > > > Hi everyone, I'm having trouble trying to find the x,y-coordinate > position of components > > within my application. I'm a brand new Flex developer with > experience in Java, C, Python, > > PHP, ColdFusion, etc. but no experience with Flash or ActionScript. > > > > In short, my question is: is there an easy way to find the location > of a component within > > the window? I have a number of buttons added programatically whose > .x and .y properties > > are all just 0. It seems like this should be a simple task, but I > have tried for hours and > > failed. > > > > The situation in detail is this: > > In my MXML, I have defined a Grid inside of my Application. The Grid > is placed with > > horizontalCenter=0 and paddingTop=50. Inside of the grid is a > GridRow containing an > > empty GridItem. Upon creationComplete of the Application, a function > is called which > > instantiates a subclass of Tile, and adds it to the empty GridItem > with addChild. In > > addition, the Tile subclass has a constructor which creates and > places a number of > > buttons inside the Tile. (There are also other rows and items in the > Grid containing some > > other components.) > > > > So in essence the structure is: Application -> Grid -> GridRow -> > GridItem -> Tile -> > > Buttons. > > > > This all looks just the way I want it to and functions fine, except > I am unable to find the > > location coordinates of the Buttons. All of the buttons as well as > the Tile itself have x and y > > as 0. I have tried using the localToGlobal to convert, but this > doesn't work since the > > buttons don't even have an x,y relative to the parent, they simply > have an x,y of 0. > > > > I feel like someone may want to know why I need the position of the > button. The specific > > answer is that I want to place a series of additional labels on top > of it, but the general > > answer is that it just seems like something a developer should be > able to do when working > > with a GUI. > > > > Any help would be greatly appreciated! Thanks. > > > > > -- "Good people will do good things, and bad people will do bad things. But for good people to do bad things—that takes religion." :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED]