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: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of flexawesome
Sent: Monday, September 10, 2007 7:11 PM
To: flexcoders@yahoogroups.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> "
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 flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> Might be event.currentTarget.parent.x. There is no Label1 in your
> sample. Also see localToGlobal
> 
> 
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>

[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of flexawesome
> Sent: Monday, September 10, 2007 11:43 AM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%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> > "
> 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>
>



 

Reply via email to