2009-09-21 28 views
9

有沒有辦法獲得EventDispatcher的註冊監聽者列表?Flash AS3 EventDispatcher - 獲取已註冊偵聽器列表的任何方式?

我知道EventDispatcherhasEventListener方法來告訴你是否有聽衆註冊,但有沒有簡單的方法來詢問EventDispatcher找出聽衆是什麼?

我想要做到這一點的一種方法是將子類EventDispatcher覆蓋addEventListener方法並將偵聽器存儲在字典中,但這對我來說感覺很笨拙。

任何想法?

+0

一直渴望一些可能的事情,但你提到的解決方案似乎是迄今爲止唯一的解決方案... – 2009-09-21 01:46:56

回答

1

它看起來並不像這是一個完整的解決方案,但它可能會幫助你的方式:

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

從文章:

上面的例子顯示我們如何獲取 對EventDispatcher中聲明的不同收聽者 的引用,以及 如何刪除它們而不具有直接 引用(並知道事件名稱arggg)。

儘管這可以幫助你 計算出,如果使用EventDispatcher有 聽衆或不存在還在 幾個問題,你會發現:

* 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 
+1

這是有幫助的,但它並不能真正解決我的問題 - 如果它只適用於調試器版本的播放器我不能用於任何真實世界的應用程序... – Reuben 2009-09-21 23:25:03

相關問題