there wasnt much out there that pointed me in the right direction to
do this. I assumed you just make the new Point based on the object
(in this case a button) and call the localToGlobal function. well,
that aint the way its done! you have to get the container (in this
case a canvas) too and then you take the containers Point and get the
containerToGlobal (the button) from it. Maybe my brain is just fried
and everybody already knows this, but i spent alot of time figuring it
out and the adobe docs didnt help me at all
this function is an example of getting global vars of buttons inside
of a container....
private function getNextProgramGlobal():Point
{
var mainCanvasPoint:Point = new
Point(mainCanvas.x,mainCanvas.y); //get the mainCanvas X and Y
vas to a point
var nextButtonPoint:Point= new Point(nextButton.x,
nextButton.y); //start to convert to global X and Y of the button
//set the mainCanvasPoint to the content of the main canvas (the
//button we are highlighting). this is where i had the problem now
//fixed.
mainCanvasPoint = mainCanvas.contentToGlobal(nextButtonPoint);
return mainCanvasPoint;
}
i hope it helps someone out!!
--- In [email protected], "Gordon Smith" <[EMAIL PROTECTED]> wrote:
>
> If you want to determine the global coordinates of the upper-left corner
> of a component, you do
>
> myComponent.localToGlobal(new Point(0, 0));
>
> not
>
> myComponent.localToGlobal(new Point(myComponent.x, myComponent.y));
>
> The upper-left corner of a component in its own coordinate system is (0,
> 0).
>
> Its x and y coordinates give its upper-left corner in its parent's
> coordinate system.
>
> Gordon Smith
> Adobe Flex SDK Team
>
> ________________________________
>
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Corey Smaller
> Sent: Wednesday, January 16, 2008 2:58 PM
> To: [email protected]
> Subject: [flexcoders] Re: localToGlobal X position
>
>
>
> I lied, the X and Y position is returning god knows what, all i know
> is its wrong.
> //compare the next highlighted component with the button found in arr
> if(buttonArray[arr] == focusManager.getNextFocusManagerComponent())
> {
> //start to convert to global X and Y
> var pt:Point= new Point(buttonArray[arr].x,buttonArray[arr].y);
> var maskPoint:Point = new Point(testCanvas.x,testCanvas.y);
> maskPoint = testCanvas.localToGlobal(maskPoint);
> trace("local mask" + maskPoint);
>
> pt = buttonArray[arr].contentToLocal(pt);
> trace("content tolocal for "+ buttonArray[arr].label +
> "="+ pt);
> }
>
> weird
>
>
> >
>