Flash AS3 EventDispatcher - any way of getting a list of registered listeners?

后端 未结 2 2119
忘了有多久
忘了有多久 2021-02-08 16:08

Is there any way of getting a list of registered listeners for an EventDispatcher?

I know that EventDispatcher has the hasEventListener

2条回答
  •  北恋
    北恋 (楼主)
    2021-02-08 16:16

    It doesn't look like this is a complete solution but it might help you on your way:

    http://www.rialvalue.com/blog/2009/09/08/does-an-eventdispatcher-have-subscribed-listeners/

    From the article:

    The example above shows how we can get a reference to the different listeners declared in an EventDispatcher and how to remove them without having a direct reference (and knowing the event name arggg).

    Even though this can help you to figure out if an EventDispatcher has listeners or not there’re still several problems you might find:

    * You don’t have any information about the listener
    * You don’t know which event the listener is listening to
    * We don’t know which phase the listener is listening to
    * Haven’t done too much testing around this, but I think both weak and strong references are hold in the list
    * The other thing to consider is that flash.sampler.getMemberNames only works in the debugger version of the Flash Player
    

提交回复
热议问题