PDA

View Full Version : multiple listeners


brokes
11-12-2009, 06:50 AM
if you say more than once for example (by mistake or whatever):

addEventListener(Event.ENTER_FRAME, onEnterFrame)
addEventListener(Event.ENTER_FRAME, onEnterFrame)

does this mean that now you have running this twice or ... ?
(if you get what i mean)

p_seilers
11-12-2009, 07:03 AM
I'm not the most experienced ActionScript developer, but from my experience: yes, the second event listener won't replace the first one. I think it is also mentioned somewhere in the adobe help documents..

evride
11-12-2009, 07:06 AM
ya, that will work in AS3.

tho if you ever have to code something in AS2, adding a second listener will not work.

flashForever01
11-12-2009, 09:39 AM
If you put 2 seperate instance names attach them to event listeners with the same function all that happens is both instance names when evoked perform the same action.

henke37
11-12-2009, 01:24 PM
addEventListener checks for duplicates. It ignores duplicate additions. But this only works if it is the exact same dispatcher, event type, catch mode and listener function.