0 Replies Latest reply on Jan 3, 2008 10:31 PM by kaushal_bs

    getting incorrect values while using getLineMetrics()

    kaushal_bs Level 1
      following e.g. finding x position of word "Adobe flex".

      if container of TextArea is not scaled then its giving correct value
      but after doing zoomin/zoomout its giving incorrect value

      Plz help me to figure out this.

      Thanks

      Kaushal

      ------------------------------------

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="absolute">

      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;

      private function onClick():void{
      cnvs.scaleX = cnvs.scaleY = 1;
      cnvs.validateNow();

      var obj:TextLineMetrics = ta.getLineMetrics(0);
      lbl.text = "X: " + String(obj.x);
      }

      private function onZoom(val:Number):void{
      cnvs.scaleX = cnvs.scaleY += (0.25 * val);
      }

      ]]>
      </mx:Script>
      <mx:Button x="75" y="285" label="Find X" click="onClick()"/>
      <mx:Canvas x="75" y="10" width="382" height="201" id="cnvs">
      <mx:TextArea x="4" y="46" color="#000000" id="ta"
      borderStyle="none" textDecoration="underline" text="adobe flex"
      fontSize="28" width="361" height="54" textAlign="center"/>
      </mx:Canvas>
      <mx:Button x="75" y="219" label="-" click="onZoom(-1)"/>
      <mx:Button x="123" y="219" label="+" click="onZoom(1)"/>
      <mx:Label x="159" y="287" text="" fontSize="13" fontWeight="bold"
      id="lbl"/>


      </mx:Application>