gpt4 book ai didi

apache-flex - Flex/AS3 - 使用字符串动态调用函数?

转载 作者:行者123 更新时间:2023-12-03 21:20:27 25 4
gpt4 key购买 nike

是否可以使用字符串值作为函数名称在 AS3 中调用函数,例如

var functionName:String = "getDetails";

var instance1:MyObject = new MyObject();

instance1.functionName(); // I know this is so wrong, but it gets the point accross:)

更新

@Taskinoor 关于访问函数的回答是正确的:
instance1[functionName]();

要访问我们将使用的属性:
instance1[propertyName]

最佳答案

实例1[函数名]();

查询 this一些细节。

关于apache-flex - Flex/AS3 - 使用字符串动态调用函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4489291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com