1 Reply Latest reply on Sep 12, 2007 9:32 PM by raghunathrao

    How to get textInput position?

      Hi there,

      I have a problem to get the textInput position... whatever I resize the browser, it keeps display "56" -_-, can anybody help on this?


      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">


      //import mx.controls.Alert;

      private function createMsg(event:Event):void
      var xPos:int = ti_2.x;



      <mx:FormItem label="Label1">
      <mx:TextInput id="ti_1" />

      <mx:FormItem label="Label2">
      <mx:TextInput id="ti_2" />

      <mx:FormItem label="Label3">
      <mx:TextInput id="ti_3" />

      <mx:Button label="Button" click="createMsg(event);"/>

        • 1. Re: How to get textInput position?
          raghunathrao Level 1
          Hi aceflex,

          The x & y positions of any component is with respect to its parent and so even when you resize it does not change.

          What you need is the global co-ordinates of your textInput and that can be done by calling localToGlobal() function of the textInput. You would need to alter your createMsg() method like below.

          private function createMsg(event:Event):void
          var xpos:int = (ti_2.localToGlobal(new Point(0,0))).x;

          The new Point(0,0) signifies the top left corner of the text input and we are then translating this to the global, i.e. te stage level