thanks alex
--- In flexcoders@yahoogroups.com, Alex Harui <aha...@...> wrote:
>
> If tool and targ have the same parent, then a simple assignment of the x,y
> should be good enough, assuming that both are drawing into positive
> coordinates only. If you've got something drawing into negative coordinates
> because it is centering and rotation, then you need more calculations.
>
> If their parents are different, and it sound like they are, then if targ is
> from a mouseEvent, the mouseEvent's stageX/Y should be good enough to back
> calculate using globalToLocal. Note that for a mouseEvent, the event.target
> could be a sub-component and thus not have the same parent as the other.
>
> Alex Harui
> Flex SDK Developer
> Adobe Systems Inc.<http://www.adobe.com/>
> Blog: http://blogs.adobe.com/aharui
>
> From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
> Behalf Of flexaustin
> Sent: Saturday, September 19, 2009 2:27 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] x and y localToGlobal
>
>
>
> Can anyone tell me if any of these are correct? I am using Senocular
> TransformTool (e.g.
> http://www.sephiroth.it/weblog/archives/2007/07/transformtool_modification.php)
> I have a Flex that has the following layers:
>
> Flex Project Layers (top to bottom):
> -Application
> --main sprite
> ---visualization sprite
> ----holder layer - where TARG and TOOL are located.
>
> What I need is for TOOL's X & Y to be TARG's X & Y at all times. So if I drag
> TARG then TOOL needs to stay with it in the same spot (And no I can't put
> TOOL inside TARG). So I tried the following which doesn't work:
>
> tool.x = targ.x; (in debug it shows this before assignment tool.x=289 and
> targ.x=0)
> tool.y = targ.y; (in debug it shows this before assignment tool.y=200 and
> targ.y=0)
>
> So, I tried each of the following (substituting in each var), but none of
> which works.
> tool.x = gtlpt.x;
> tool.y = gtlpt.y;
>
> var gtlpt:Point = tool.globalToLocal( new Point( targ.x, targ.y ) );
> var ltgpt:Point = tool.localToGlobal( new Point( targ.x, targ.y ) );
>
> var toolgtlpt:Point = targ.globalToLocal( new Point( tool.x, tool.y ) );
> var toolltgpt:Point = targ.localToGlobal( new Point( tool.x, tool.y ) );
>
> var mgtlpt:Point = _vis.marks.globalToLocal( new Point( tool.x, tool.y ) );
> var mltgpt:Point = _vis.marks.localToGlobal( new Point( tool.x, tool.y ) );
>
> var mmgtlpt:Point = _vis.marks.globalToLocal( new Point( targ.x, targ.y ) );
> var mmltgpt:Point = _vis.marks.localToGlobal( new Point( targ.x, targ.y ) );
>