views:

922

answers:

1

Given a Function object, can you get its name as a String? See example:

function doThingWithCallback(callback:Function):void {
   trace("i'm going to run " + callback); // outputs "i'm going to run function Function() { }"
}

function foo():void {
   ...
}

doThingWithCallback(foo);

This example is sort of arbitrary, but it would be very useful to get function names for debugging, particularly when passing around Function objects.

+1  A: 

See the best answer to this question.

To my knowledge, the name of a function can only be determined while the function is on the callstack.

Evan Rogers