Skip to main content
Participant
August 4, 2008
Answered

Is there a way to see what eventListeners currently exist?

  • August 4, 2008
  • 2 replies
  • 504 views
I've currently got a function in which a event listener is added (addEventListener(Event.ENTER_FRAME, create Animation) but I am calling the function repeatedly in my program it is giving me an error:

ArgumentError: Error #1063: Argument count mismatch on Projectv017_fla::MainTimeline/createAnimation(). Expected 0, got 1.

Which I assume is an error saying that this event listener already exists. Is this correct? If so, I'm wondering if anyone knows if there is a way I can see whether the listener already exists so I can write an if statement around the addEventListener so that it only creates the event listener if it doesn't already exist. I want to do this because I want to add and remove the event listener occasionally in my program because I don't need it to always be running, but want it to be turned on and off.
This topic has been closed for replies.
Correct answer Andrei1-bKoviI
What is the syntax for your function? It should be:
function createAnimation(e:Event):void {}

If you want to check if the listener exists:

hasEventListener(Event.ENTER_FRAME)

2 replies

Andrei1-bKoviICorrect answer
Inspiring
August 4, 2008
What is the syntax for your function? It should be:
function createAnimation(e:Event):void {}

If you want to check if the listener exists:

hasEventListener(Event.ENTER_FRAME)
Participant
August 4, 2008
Your right Andrei1, I forgot to put the e:Event parameter into the createAnimation function. I've put it in and it now works fine, no problems. Thanks for your help.
August 4, 2008
I can't reproduce the error, but hasEventListener might be, what you are looking for.