我們如何動態調用函數。我曾嘗試下面的代碼:動態調用函數
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