1 Reply Latest reply on Apr 22, 2008 9:50 PM by levancho


      Okay so if I have a the following components


      If BOTH my panel AND my button has an event handler addEventListener(Event.click, somehandler) and I click button, should I use currentTarget or target, and why? am I right in thinking currentTarget will end up with a value of panel and not button, since it will stop propagation?do both listeners get executed(if they say had different handlers)?

      I read the flex F1 help screens and they explained it but I'm still a litte unsure, any actionscript gurus that can clear it up for me, I would be most greatful.
        • 1. Events
          levancho Level 3
          for example you have listener myButtonListiner, and you register it with component Button as click event handlers.and also you have another listner myPanelListener that you regiter with Panel as click event handlers as well.

          now you move your shiny mouse over button and perform a click.

          target attribute is not guaranteed to be an object that you want,(in this case button) thats because, when you click on button, button also have a text label,or text field as child , (not sure which one it has, but does not matter) component, so if during the click your mouse pointer was on top of label of the button then target property will point to label because label is the object that initiated a click event, after all, you did click on a buton's label and not your button even thought label is visually part of the button. behind the scens there is :
          -- Button
          |--Button Label
          -- etc ...
          also target attribute once set does not change, so during bubbling targt attribute states the same.
          , on other hand currentTarget is context relative and changes on every "bubble step". that means :
          when your myButtonListiner gets called, currentTarget will be button and when your myPanelListener gets called currentTarget will be Panel. and so on and so on until event object reaches the top-most component and runs out of bubbles.

          this is my understanding of how these two attributes differ.