----- Original Message ----- 
  From: Parkash 
  To: [email protected] 
  Sent: Monday, November 03, 2008 5:13 PM
  Subject: [flexcoders] MultipleEvents


  Hi every one i have one simple textfiled with focusout event  and button with 
click event.

  Now when i entered some text in textinput and when clicks on button , 
according to me two events shoud be dispatched at a time ( plz correct me i am 
wrong ), one textfield focusout and second button clicks event. but for some 
reason it dispatches only one event i.e focus out ca any one tell to to resolve 
this problem i want to dispatch both events @ the same time here os code sapmle.

Hi Parkash,

Normally you would get two events, but your test example actually stops the 
second event from happening!

If you click the button (without entering a text field) you get "1" in the 
Alert box -as expected.

If you put the cursor into a text field, and then click the button you get "2" 
in the alert box - as expected, but a second alert box doesn't appear with a 
"1" in it  - unexpected.

The reason is described in this abstract from the documentation about the 
"click" event:

"For a click event to occur, it must always follow this series of events in the 
order of occurrence: mouseDown event, then mouseUp. The target object must be 
identical for both of these events; otherwise the click event does not occur."

When you click on the button after putting the cursor into the textinput, at 
the start of the click the mouse is down over the button - this causes the text 
to lose focus and fire an event - so the Alert box is presented. By now the 
mouse is no longer over the original button and so the mouse down/mouse up 
sequence is broken for the button because a modal dialog has popped up so the 
click event is never fired.

If you replace the alert boxes with trace statements and run it through the 
debugger, you'll find it works as you expect it to..

Paul



  Thanks In Advance 

  Parkash ARjan....



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

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

  <mx:Script>

  <![CDATA[

  import mx.controls.Alert;


  public function buttonClicked():void

  {

      Alert.show('1'); 

  }

  public function textInputFocusOut():void

  {

      Alert.show('2');

  }


  ]]>

  </mx:Script>


  <mx:TextInput focusOut="{textInputFocusOut()}" />

  <mx:Button click="{buttonClicked()}"/> 


  </mx:Application>


   

Reply via email to