Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 03-01-2010, 09:48 PM   #1
davids701124
Registered User
 
Join Date: Aug 2009
Posts: 42
Default e.target vs e.currentTarget

Hi folks,

I'm trying to clarify the difference of e.target and e.currentTarget. I always just pick one of them, sometimes it doesn't really matter. I think, because in some situation e.target = e.currentTarget.

However, I really wanna full understand their difference and how could I know I should use which one in which situation.

anyone could explain well??
davids701124 is offline   Reply With Quote
Old 03-01-2010, 09:59 PM   #2
maskedMan
Obfuscated Coder
 
maskedMan's Avatar
 
Join Date: Apr 2008
Posts: 1,571
Default

currentTarget is the object on which you called .addEventListener.
target is the object that originally dispatched the event.

target will only be different from currentTarget if the event is "bubbling." In other words, only from a DisplayObject on the display list that happens to be a child (or grandchild, or further) of the object to which you added the listener.

Let's say you add MouseEvent.CLICK to foo_mc, which contains bar_mc, which contains goober_mc like this:
Code:
foo_mc
  + bar_mc
     + goober_mc
so if you click goober_mc, you'll get currentTarget = foo_mc (because that's where you added the listener) and target = goober_mc because that's the clip you clicked.
__________________
http://www.scriptocalypse.com - It's not the end of the world. It's just Actionscript!

man.mask = mask_mc;

Last edited by maskedMan; 03-01-2010 at 10:02 PM.
maskedMan is offline   Reply With Quote
Old 03-02-2010, 02:24 AM   #3
davids701124
Registered User
 
Join Date: Aug 2009
Posts: 42
Default

Quote:
Originally Posted by maskedMan View Post
currentTarget is the object on which you called .addEventListener.
target is the object that originally dispatched the event.

target will only be different from currentTarget if the event is "bubbling." In other words, only from a DisplayObject on the display list that happens to be a child (or grandchild, or further) of the object to which you added the listener.

Let's say you add MouseEvent.CLICK to foo_mc, which contains bar_mc, which contains goober_mc like this:
Code:
foo_mc
  + bar_mc
     + goober_mc
so if you click goober_mc, you'll get currentTarget = foo_mc (because that's where you added the listener) and target = goober_mc because that's the clip you clicked.
seems clear for me.
Thanks dude.
davids701124 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 06:01 AM.

///
Follow actionscriptorg on Twitter

 


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