Hok's Macromedia Flash Blog

macromedia flash actionscript scripting, php, remoting, webservices, c#, javascript

Ads

Search

Debugging: setFunctionNames

Sometimes it is important to know what function exactly
calls a function or a method. Making use of the function
above you can simply determine the caller by tracing the
'arguments.caller.name' within a function.
setFunctionNames = function (pObjContainer) {
   // Description:
   // Sets the property "name" for every Function
   // that was found in "pObjContainer"
   // Arguments:
   // pObjContainer -> Obj|Mc in which to rekusivly
   //      search for functions
   pObjContainer = pObjContainer || _root;
   for (var p in pObjContainer) {
      if (typeof pObjContainer[p] == 'object') {
        arguments.callee(pObjContainer[p]);
      } else if (typeof pObjContainer[p] == 'function') {
        pObjContainer[p].name = p; // <-- sets the name
        arguments.callee(pObjContainer[p].prototype);
      }
   }
}

Posted by hOk at April 7, 2003 04:29 PM

Comments (0)


Name:


Email Address:


URL:


Comments:



You can use <code>code that should be highlightned</code> to highlight code!
Optionally you can use the attribut language="php|perl|java" within the code tag, otherwise
actionscript-highlightning will be used.

New Place