Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how to get id of function passed into addEventListener

Explorer ,
Jul 08, 2015 Jul 08, 2015

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

TOPICS
ActionScript
546
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 12, 2015 Jul 12, 2015

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());

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 12, 2015 Jul 12, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 12, 2015 Jul 12, 2015
LATEST

You can track identity or pair custom data (like id) by using equality operator or dictionary key. I bet there is nothing more.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines