views:

21

answers:

2

Is there any way to count (specify) the avarage amount of objects that are removed from stage and has active listeners?
I have really big project(game), more than 100 classes.. Now i scan each classes, if there are active unnecessary listeners i remove them.

Now, i wanna such a tool, which will tell me where is there any other unnecessary listeners, or at least tell me if there are everything ok.

It's like a stupid question, maybe you can suggest me any tool to control listeners.

Thank you

A: 

There isn't a packaged tool to do this, but you might be able to create some sort of mapping utility that would monitor your event listeners. This utility would supply API to allow you to add a listener to a particular object and provide the callback/handler. It would then have a map/list of all objects and their callbacks. it might provide this functionality via static methods or through dependency injection.

The Flash Builder profiler is a great tool for tracking down memory leaks, though it does not provide the specific functionality you are looking for.

Joel Hooks
Thanks for suggession
Almas Adilbek
A: 

Firstly , Try using weak event listener so that they are removed when any DisplayObject is set to Null. Secondly, You have to build this functionality on your own. For example to figure out the invisible objects that have Mouse CLICK event attached in MainContainer DisplayObject. you can use following code

For (var j:int=0; j< MainContainer.length; j++) {

var Obj = MainContainer.getChildAt(j);
if(!Obj.visible && Obj.hasEventListener(MouseEvent.CLICK)) { // do something }

}

Muhammad Irfan
Thank u bro, it would be useful for me
Almas Adilbek