PDA

View Full Version : EventListener Question


kgaard
02-14-2008, 07:08 PM
So, I've trolled the net for about an hour now trying to figure this out, and it's definitely one of those "I'm sure there's a way, but I don't know what it is" scenarios -

I have the code:

b1pic.addEventListener(MouseEvent.MOUSE_OVER, goPics)

which works wonderfully, but what I'm wondering is - is there a way, once the function goPics is called, is there a way to obtain the object that called it? So, once goPics fires, how can I get that b1pic called it?

is there a native way to do this? or even a way to pass a variable with the function when its called by the EventListener? I guess, the equivalent of calling goPics(b1pic)?

any help would be mucho appreciated!

bahamucio
02-14-2008, 07:18 PM
just use
event.target or event.currentTarget

kgaard
02-14-2008, 07:28 PM
ok, forgive me here, I'm missing AS2 right now :)


if I have:

function goPics(event){
trace(event.target)
}



I get back: "[object Loader]"

which is fine, so if I say:

function goPics(event){
trace(event.target.name)
}



i get back "instance111"

I tried explicitly saying:


b1pic.name = "b1pic"


which seems dumb anyway, but regardless it didn't work either..

any ideas?

thank you!!!!