Copy link to clipboard
Copied
I need to get some identifier for the function being passing to addEventListener to try to find where a bogus second handler is getting added to a library I am using.
using this in a wrapper function around EventDispatcher.addEventListener
override function addEventListener (type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false) : void;
if ( "mouseDown" == type)
trace( addEventListener type: " + type + " listener: " + listener )
I see in my logs
addEventListener type: mouseDown listener: function Function() {}
which is not much good.
In the debugger I see an id associated with the function, how can I get that id? or some unique identifier.
Like this
EventCollector.addEventListener: mouseDown func: 23449322
or ideally
EventCollector.addEventListener: mouseDown func: className.functionName.instanceId
bob
Copy link to clipboard
Copied
In the debugger you see object id visible only to debugger connection. It is possible to access it with custom debugger, but it is not general solution.
You will find that place just by printing stack trace in your wrapper, like this: trace(new Error().getStackTrace());
Copy link to clipboard
Copied
Thx pp8788946
That just shows you the stack. The stack has nothing to do with the function that was passed in as the "call back function".
Error: Stack Trace Test
at com.voxelengine.events::ModelMetadataEvent$/addListener()
at com.voxelengine.worldmodel.models::ModelMetadataCache$/init()
at VVInitializer$/initialize()
at VoxelVerse/init()
I can see that my addListener function was called from the ModelMetadataCache.init function. What I want to know it what is an "identifier" for the call back function that was passing in to the addListener.
static public function addListener( $type:String, $listener:Function, $useCapture:Boolean = false, $priority:int = 0, $useWeakReference:Boolean = false) : void {
... }
I want to know the ID or something unique about the $listener:Function.
bob
Copy link to clipboard
Copied
You can track identity or pair custom data (like id) by using equality operator or dictionary key. I bet there is nothing more.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now