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

    How to get textInput position?

    aceflex
      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?



      Cheers


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

      <mx:Script>
      <![CDATA[

      //import mx.controls.Alert;

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

      ]]>
      </mx:Script>

      <mx:Panel>
      <mx:Form>

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

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

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

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

      </mx:Application>
        • 1. Re: How to get textInput position?
          raghunathrao
          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;
          trace(xpos);
          }

          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