Vishwas
Vishwas

Reputation: 1541

Getting instance of button/movieclip on it's click's handler

It used to happen in AS2.0 as follows :

my_Mc.onPress  = function()
{
   trace( this) 
}

//output : 
[my_Mc Movieclip]

However in AS3.0, i wonder how to achieve this

my_Mc.addEventListener( MouseEvent.CLICK, click) ;

function click(e:Event)
{
   trace( this ) ;  // output is the class instance, where the handler is being used 
// How to get the instance of my_Mc here ???? 
}

thanks.

Upvotes: 0

Views: 203

Answers (1)

Rick van Mook
Rick van Mook

Reputation: 2065

What you're looking for is the e.currentTarget property.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/Event.html#currentTarget

Upvotes: 2

Related Questions