Skip to main content
February 10, 2011
Question

Is it safe to call addEventListener multiple times?

  • February 10, 2011
  • 2 replies
  • 3749 views

camera.addEventListener( ActivityEvent.ACTIVITY, onTriggerRecordStart );

Or do I make sure that the above script is only called once?

UPDATE

Can I register two different functions to the same event?

    This topic has been closed for replies.

    2 replies

    Participating Frequently
    March 26, 2011

    First off, if you never call:

    camera.removeEventListener( ActivityEvent.ACTIVITY, onTriggerRecordStart );

    (note the 'remove' instead of 'add) then it will work every time there in an activity event.  Just set it once and it will listen for any events on the camera relating to that event.  It will do this multiple times and won't stop untill you remove it.  So just add it once.

    March 26, 2011

      @Next2Heaven 

    I know it'll be OK if I only call addEventListener once.

    The problem is ,will it be OK to bind it many times?

    camera.addEventListener( ActivityEvent.ACTIVITY,onTriggerRecordStar)

    Participating Frequently
    March 27, 2011

    Sure.  You could bind it multiple times.  It won't make a difference in how it reacts.

    Participating Frequently
    February 10, 2011

    Why would you want to do that?

    March 26, 2011

    Because I need to call it when the user updates his settings:

    camera.addEventListener( ActivityEvent.ACTIVITY, onTriggerRecordStart );

    And the user may update many times,so I'm not sure when it's safe to call the above script multiple times.

    I can't find any detailed reference regarding this issue.