1 Reply Latest reply on Oct 15, 2008 4:34 AM by anirudhs

    question about event objects


      I am confused about target vs currentTarget.

      In the day 1 video: Introducing the event object, near the end (around 9.30) I read that the differences between target vs currentTarget. One point says that the target always refers to the event dispatcher.

      So I'm thinking that if I set the event listener to the button, the target will always be button. And if I set the event listener to the panel (as in the video, around 10.28), I would have thought that the target would then be the panel, but the video says its still the button. That's the part I don't understand.

      Can anyone shed some light on this for me?

        • 1. Re: question about event objects
          anirudhs Level 2

          target is the event dispatcher. currentTarget is the level at which the listeners were executed. Take a button. When you click on it, the click might be on the UITextField (label of the button). The event bubbles up to the Button (of which UITextField is a child) and any click listeners attached to the button executes with target as UITextField and currentTarget as the button.

          Now consider the Panel case. When you have a click listener on the panel and you click on the button, button got the click, the event bubbles up to the parent. target will be the dispatcher (button) and currentTarget will be where the listener is at (Panel).

          Read up more about it at: http://livedocs.adobe.com/flex/3/html/help.html?content=events_08.html#203937