Flex/AS3 - 使用字符串动态调用函数? [英] Flex/AS3 - calling a function dynamically using a String?
本文介绍了Flex/AS3 - 使用字符串动态调用函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用字符串值作为函数名称来调用 AS3 中的函数,例如
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:)
更新
@Taskinoor 关于访问函数的回答是正确的:
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.
这篇关于Flex/AS3 - 使用字符串动态调用函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文