View Full Version : eventlisteners, focus and other madness

07-27-2006, 07:51 PM
well i built this as a demo of my problem.

i am trying to capture the event when i text field looses focus. but when i use the following code, here is what happens.

1. user clicks into text field.
2. user hits tab
3. in background the focus changes
4. event fires for lost focus (you see alert)
5. use hits ok to clear alert box
6. original textbox gets focus
7 event triggers again.

maddness i say maddness.

so how do i get it to trigger the event just when "I" use mouse or use keyboard????

here is my code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initializeApp();" layout="absolute">

import mx.controls.Alert;

private function initializeApp():void
private function createListeners():void
txtOne.addEventListener(FocusEvent.FOCUS_OUT,addDa taItem);
txtTwo.addEventListener(FocusEvent.FOCUS_OUT,addDa taItem);
private function addDataItem(e:Event):void
var curTargName:String=e.currentTarget.name;
var tarName:String=e.target.name;


<mx:TextInput id="txtOne" text="" x="10" y="10"/>
<mx:TextInput id="txtTwo" text="" x="10" y="50"/>

im a noob. so any help (even OT) is appreciated.