在Flex中,从功能对象中获取函数名 [英] in flex, get function name from Function object
本文介绍了在Flex中,从功能对象中获取函数名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给出一个函数对象,你可以得到它的名字作为一个字符串?见例如:
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.
推荐答案
看到最好的答案<一个href="http://stackoverflow.com/questions/711404/can-an-actionscript-function-find-out-its-own-name">this问题。
据我所知,一个函数的名称只能在功能上调用堆栈确定。
To my knowledge, the name of a function can only be determined while the function is on the callstack.
这篇关于在Flex中,从功能对象中获取函数名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文