我们如何动态调用函数。我曾尝试下面的代码:动态调用函数
public function checkFunc() : void
{
Alert.show("inside function");
}
public var myfunc:String = "checkFunc";
public var newFunc:Function=Function(myfunc);
newFunc();
但它给错误:
Call to a possibly undefined method newFunc.
在地方newFunc()
,我试着给它this[newFunc]()
,但抛出的错误:
The this keyword can not be used in static methods. It can only be used in instance methods, function closures, and global code
任何帮助动态调用函数?
可能的复制(http://stackoverflow.com/questions/4489291)的Flex/AS3的 – 2015-01-07 23:41:52
可能重复的 - 调用一个函数动态地使用一个字符串?](http://stackoverflow.com/questions/4489291/flex-as3-calling-a-function-dynamically-using-a-string) – RaYell 2015-01-08 09:08:42