In an actionscript function (method) I have access to arguments.caller which returns a Function object but I can’t find out the name of the function represented by this Function object. Its toString() simply returns [Function] and I can’t find any other useful accessors that give me that… Help :-/
In an actionscript function (method) I have access to arguments.caller which returns a Function
Share
I found an answer and I’ll paste it below.
@fenomas: yes, you are right of course, functions are just objects and what I’m looking for is a the name of the reference to them (if exists, i.e. the function is not anonymous). You also right that in general this doesn’t look like the best way to do programming 😉 But my scenario is special: I want to implement a Checks class (similar to C CHECK) with methods such as Check.checkTrue and Checks.checkRef in which when the check fails I get a nice trace. The traces will appear only in debug version, not in release.
I’m using MTASC and the code below only works with MTASC. It should also be used only for debugging purposes and not release. The technique is to iterate on _global and find a function that’s equal to my calling function. It’s a hack that does not always work (anonymous) but it serves me pretty well in most cases.