Assuming that what you want is global coordinates, it's even simpler to
do
event.currentTarget.localToGlobal(new Point(0, 0)).x
which works because the upper-left of any component is (0, 0) in its own
local coordinate system.
- Gordon
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of flexawesome
Sent: Tuesday, September 11, 2007 8:32 AM
To: [email protected]
Subject: [flexcoders] Re: How to get Textinput position?
you are SO COOL. Thank you so much :)
have a nice day
--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Sven Woermann" <[EMAIL PROTECTED]>
wrote:
>
> Hi, try this. You are basically calling the localToGlobal method on
the
> parent container of the TextInput and give it the position of the
TextInput
> relative to it's parent.
>
> event.currentTarget.parent.localToGlobal(new
Point(event.currentTarget.x,
> event.currentTarget.y)).x
>
>
>
>
> On 9/11/07, flexawesome <[EMAIL PROTECTED]> wrote:
> >
> >
> > Hi Gordeon,
> >
> > Thank you so much to reply it as I am new to flex, and don't know
how
> > to use localToGlobal() it in my app below, I am appreciate if you
> > can show me the code , that would be great!
> >
> > THANKS :)
> >
> >
> > --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> <flexcoders%40yahoogroups.com>,
"Gordon
> > Smith" <gosmith@> wrote:
> > >
> > > The x and y properties of a DisplayObject are in the coordinate
> > system
> > > of its parent. So you're getting the location of the top-left of
the
> > > TextInput relative to the top-left of the FormItem. If you want
> > > coordinates in a different coordinate system, use localToGlobal()
> > and
> > > globalToLocal().
> > >
> > > - Gordon
> > >
> > > ________________________________
> > >
> > > From: [email protected]
<mailto:flexcoders%40yahoogroups.com> <flexcoders%40yahoogroups.com>
> > [mailto:[email protected]
<mailto:flexcoders%40yahoogroups.com> <flexcoders%40yahoogroups.com>]
On
> > > Behalf Of flexawesome
> > > Sent: Monday, September 10, 2007 7:11 PM
> > > To: [email protected]
<mailto:flexcoders%40yahoogroups.com> <flexcoders%40yahoogroups.com>
> > > Subject: [flexcoders] Re: How to get Textinput position?
> > >
> > >
> > >
> > >
> > > humm...parent doesn't work... and I correct the code below..
> > >
> > > Cheers
> > >
> > > ================================
> > >
> > > <?xml version="1.0"?>
> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml>
> > > <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> >
"
> > > viewSourceURL="srcview/index.html">
> > > <mx:Script>
> > > <![CDATA[
> > >
> > > import mx.core.IFlexDisplayObject;
> > > import mx.core.UIComponent;
> > > import mx.controls.Alert;
> > >
> > > private function createMsg(event:Event):void {
> > >
> > > var target:UIComponent = UIComponent(event.currentTarget);
> > >
> > > var alert:Alert;
> > >
> > > Alert.show("the X position of LABEL 1 is "+event.currentTarget.x,
> > > "Show Me", Alert.YES | Alert.NO)
> > > }
> > >
> > > ]]>
> > > </mx:Script>
> > >
> > > <mx:Panel>
> > > <mx:Form>
> > > <mx:FormItem label="Label1">
> > > <mx:TextInput focusOut="createMsg(event);"/>
> > > </mx:FormItem>
> > > <mx:FormItem label="Label2">
> > > <mx:TextInput/>
> > > </mx:FormItem>
> > > <mx:FormItem label="Label3">
> > > <mx:TextInput/>
> > > </mx:FormItem>
> > > </mx:Form>
> > > </mx:Panel>
> > >
> > > </mx:Application>
> > >
> > > --- In [email protected]
<mailto:flexcoders%40yahoogroups.com>
<flexcoders%40yahoogroups.com><mailto:
> > flexcoders% <flexcoders%25>
> > 40yahoogroups.com>
> > > , "Alex Harui" <aharui@> wrote:
> > > >
> > > > Might be event.currentTarget.parent.x. There is no Label1 in
your
> > > > sample. Also see localToGlobal
> > > >
> > > >
> > > >
> > > > ________________________________
> > > >
> > > > From: [email protected]
<mailto:flexcoders%40yahoogroups.com>
<flexcoders%40yahoogroups.com><mailto:
> > flexcoders% <flexcoders%25>
> > 40yahoogroups.com>
> > >
> > > [mailto:[email protected]
<mailto:flexcoders%40yahoogroups.com>
<flexcoders%40yahoogroups.com><mailto:
> > flexcoders% <flexcoders%25>
> > 40yahoogroups.com>
> > > ] On
> > > > Behalf Of flexawesome
> > > > Sent: Monday, September 10, 2007 11:43 AM
> > > > To: [email protected]
<mailto:flexcoders%40yahoogroups.com> <flexcoders%40yahoogroups.com>
<mailto:
> > flexcoders% <flexcoders%25>
> > 40yahoogroups.com>
> > > > Subject: [flexcoders] How to get Textinput position?
> > > >
> > > >
> > > >
> > > > Hi guys.... :)
> > > >
> > > > I am working on flex, and looks hard to get the target object x
> > and
> > > y
> > > > position. do you have any ideas?
> > > >
> > > > Cheers & THANKS
> > > >
> > > > ================================
> > > >
> > > > <?xml version="1.0"?>
> > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml>
> > > <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> >
> > > > <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml>
<http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> >
> > > "
> > > > viewSourceURL="srcview/index.html">
> > > > <mx:Script>
> > > > <![CDATA[
> > > >
> > > > import mx.core.IFlexDisplayObject;
> > > > import mx.core.UIComponent;
> > > > import mx.controls.Alert;
> > > >
> > > >
> > > > private function createMsg(event:Event):void {
> > > >
> > > > var target:UIComponent = UIComponent(event.currentTarget);
> > > >
> > > > var alert:Alert;
> > > >
> > > > Alert.show("the X position of LABEL 1 is
"+event.currentTarget.x,
> > > > "Show Me", Alert.YES | Alert.NO)
> > > > }
> > > >
> > > > ]]>
> > > > </mx:Script>
> > > >
> > > > <mx:Panel>
> > > > <mx:Form>
> > > > <mx:FormItem label="Label">
> > > > <mx:TextInput focusOut="createMsg(event);"/>
> > > > </mx:FormItem>
> > > > <mx:FormItem label="Label">
> > > > <mx:TextInput/>
> > > > </mx:FormItem>
> > > > <mx:FormItem label="Labe3">
> > > > <mx:TextInput/>
> > > > </mx:FormItem>
> > > > </mx:Form>
> > > > </mx:Panel>
> > > >
> > > > </mx:Application>
> > > >
> > >
> >
> >
> >
>