Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Flex > Flex 2 & 3

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-27-2006, 08:51 PM   #1
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,048
Default eventlisteners, focus and other madness

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:
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initializeApp();" layout="absolute">
<mx:Script>
    <![CDATA[
    
    	import mx.controls.Alert;
    
    	private function initializeApp():void
    	{
    		createListeners();
    	}
    	private function createListeners():void
    	{
    		txtOne.addEventListener(FocusEvent.FOCUS_OUT,addDataItem);
    		txtTwo.addEventListener(FocusEvent.FOCUS_OUT,addDataItem);    		
    	}
    	private function addDataItem(e:Event):void
    	{
    		var curTargName:String=e.currentTarget.name;
    		var tarName:String=e.target.name;
    		
    		Alert.show(curTargName,tarName);
    	}
    ]]>
</mx:Script>

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

im a noob. so any help (even OT) is appreciated.
thanks.
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:35 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.