At first I apologize for my terrible English. I have two TextInput and I want to show a tootip informing that the "caps lock is on" at the both fields. My problem is to position the tooltip because the way I was doing is not the best one. I used the global coordinates and for the first field works good, but for the second not.
somebody could explain better how to use the global coordinates with many fields, one below the other? Thank you! Carlos H. My source code follows below: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="Init()" width="100%" height="100%"> <mx:Script> <![CDATA[ import mx.managers.ToolTipManager; import mx.controls.ToolTip; public var myTip:ToolTip; private function Init():void { campo1.addEventListener(KeyboardEvent.KEY_UP, TeclaLiberada); campo2.addEventListener(KeyboardEvent.KEY_UP, TeclaLiberada); } private function TeclaLiberada(e:KeyboardEvent):void { if(Keyboard.capsLock) { if(myTip==null) CRIA_TipCapsLock(e); } else { if(myTip!=null) { ToolTipManager.destroyToolTip(myTip); myTip=null; } } } private function CRIA_TipCapsLock(e:Event):void { var posicao_x:Number; var posicao_y:Number //Pega posicao do campo que originou o CAPS var pt:Point = new Point(e.currentTarget.x, e.currentTarget.y); pt=e.currentTarget.localToGlobal(pt); switch(e.currentTarget.id) { case "campo1": posicao_x = pt.x + 40; posicao_y = pt.y - 60; break; case "campo2": posicao_x = pt.x + 40; posicao_y = pt.y - 90; break; } var s:String = "Caps Lock ON !" myTip = ToolTipManager.createToolTip(s,posicao_x,posicao_y,"errorTipAbove"); myTip.width = 100; myTip.height = 40; ]]> </mx:Script> <mx:Canvas height="96" width="232" id="canvas1"> <mx:TextInput id="campo1" y="20" x="36"/> <mx:TextInput id="campo2" y="50" x="36"/> </mx:Canvas> </mx:Application>