是否有可能使用一个字符串值作为函数名称,例如调用在AS3功能
VAR函数名:字符串=getDetails;
VAR实例1:为MyObject =新的MyObject();
instance1.functionName(); //我知道这是错的,但它得到的地步翻过:)
更新
从@Taskinoor上访问功能的答案是正确的:
实例1 [函数名();
和访问一个属性,我们可以使用:
实例1 [propertyName的]
解决方案
的实例1 [函数名();
检查这个的一些细节。
Is it possible to call a function in AS3 using a string value as the function name e.g.
var functionName:String = "getDetails";
var instance1:MyObject = new MyObject();
instance1.functionName(); // I know this is so wrong, but it gets the point accross:)
UPDATE
The answer from @Taskinoor on accessing a function is correct:
instance1[functionName]();
And to access a property we would use:
instance1[propertyName]
解决方案
instance1[functionName]();
Check this for some details.