that's because the second field really does get focus before you set it
back.  I would add dirty flags so that validation returns true if nobody
typed anything in that TextInput

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Harsha Pande
Sent: Thursday, September 27, 2007 12:35 AM
To: [email protected]
Subject: [flexcoders] Re: Problems with setFocus()



Hi Alex,
 
Thanks for your reply. The problem is now that if I have the same method
called from both the text inputs then the application is going into a
recursive loop. 
 
The application source code is attached for reference:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " layout="vertical">


<mx:Script>
 <![CDATA[
   import mx.controls.Alert;
  private function validateField(event:Event):void{
     if (TextInput(event.currentTarget).text == "abc"){
    
      } else {
          callLater(event.currentTarget.setFocus);
      }
   }
 ]]>
</mx:Script>

  <mx:TextInput id="firstInput" focusOut="validateField(event)"/>
  <mx:TextInput id="secondInput" focusOut="validateField(event)"/>
</mx:Application>


Regards,

Harsha

 

Reply via email to