> I think localToGlobal measures from the center of an object or registration point of a display object IIRC?
The local coordinate system for a DisplayObject in Flex has its origin at the upper-left corner of that DisplayObject. In other words, the upper-left corner is (0, 0) in local coordinates. There are no registration points in Flex. - Gordon ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of dorkie dork from dorktown Sent: Friday, April 20, 2007 11:18 PM To: [email protected] Subject: Re: [flexcomponents]Total distance from edge of Application Thanks Mike and Gordon, Reading through your comments and the documentation again I think that the issue here might be different backgrounds. I have no point of reference for Point objects and localToGlobal. Adding to that confusion is that I think localToGlobal measures from the center of an object or registration point of a display object IIRC? The closest thing I can think of that relates to this is relative and absolute positioning in CSS. What would make sense to me would be something like: var myPoint:Point = myComponent.getAbsolutePosition(); var myPoint:Point = myComponent.getRelativePosition(); To me a "getAbsolutePosition()" means get the absolute top and left position of myDisplayObject all the way to top of application. This would not deal with registration points. Maybe a true parameter would return the point including the registration point. Does this make sense? On 4/19/07, Gordon Smith <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: I meant to say So myComponent.localToGlobal(new Point(0, 0)) would give you the coordinates of myComponent's top-left corner in Stage coordinates. - Gordon ________________________________ From: [email protected] <mailto:[email protected]> [mailto:[email protected] <mailto:[EMAIL PROTECTED]> ] On Behalf Of Gordon Smith Sent: Thursday, April 19, 2007 8:58 PM To: [email protected] <mailto:[email protected]> Subject: RE: [flexcomponents]Total distance from edge of Application > I still have problems trying to understand localToGlobal. It doesn't make sense to me. Can we rename it or change the signature? What don't you understand about localToGlobal()? You pass in a point expressed in the "local" coordinate system of the object that you're calling localToGlobal() on. It returns the same point expressed in the "global" coordinate system of the Stage. For example, the top-left corder of any visual component is (0, 0) in its own local coordinate system. So myComponent.localToGlobal(new Point(0, 0)) would give you the coordinates of myButton's top-left corner in Stage coordinates. - Gordon ________________________________ From: [email protected] <mailto:[email protected]> [mailto:[email protected] <mailto:[EMAIL PROTECTED]> ] On Behalf Of dorkie dork from dorktown Sent: Thursday, April 19, 2007 8:49 AM To: [email protected] <mailto:[email protected]> Subject: [flexcomponents]Total distance from edge of Application I'm trying to find out the total distance in pixels my component is from the edge of the application. I have some code that attempts to get the x and y of the component but it doesnt work if its inside a container or containers. I still have problems trying to understand localToGlobal. It doesn't make sense to me. Can we rename it or change the signature? var x:int = LocationClass.getLength(myComponent,Application,x); // returns 10 var y:int = LocationClass.getLength(myComponent,Application,y); // or var y:int = LocationClass.getDistanceTo(myComponent,Application,y); thanks
