actionscript-3 actionscript event - Difference between and e.currentTarget

5 Answers is what triggers the event dispatcher to trigger and e.currentTarget is what you assigned your listener to.

listener as3 mouse

I don't understand the difference, they both seem the same but I guess they are not.

Any examples of when to use one or the other would be appreciated.

I like visual answers.

When you click #btn, two event handlers get called and they output what you see in the picture.

Demo here:

make an example:

var body = document.body,
    btn = document.getElementById( 'id' );
body.addEventListener( 'click', function( event ) {
    console.log( event.currentTarget === body );
    console.log( === btn );
}, false );

when you click 'btn', and 'true' and 'true' will be appeared!

  • is element, which you f.e. click
  • e.currentTarget is element with added event listener.

If you click on child element of button, its better to use currentTarget to detect buttons attributes, in CH its sometimes problem to use

target  is the element that triggered the event (e.g., the user clicked on)

currenttarget is the element that the event listener is attached to.