Actionscript - 获取给定类名的方法列表

发布于 2024-10-09 18:02:41 字数 34 浏览 0 评论 0原文

我想获取一个类可用的方法列表,给定其名称。我该怎么做?

I want to obtain a list of methods available to a class, given its name. How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

油饼 2024-10-16 18:02:41

这就是所谓的内省,而AS3做内省的能力是有限的。

这是您能做的最好的事情,

import flash.utils.describeType;

var data:XML = (describeType(SingleEvent));
for each (var method:XML in data.factory.method) {
    trace("Name: " + method.@name);
    trace("Returns: " + method.@returnType);
    for each (var parameter:XML in method.children()) {
        trace("Parameter " + parameter.@index + ": " + parameter.@type + ", optional: " + parameter.@optional);
    }
    trace("----------------------------");
}

不幸的是,这是限制,只能向您展示具有公共访问器的方法。您也可以查看输出

print data.toXMLString()

,看看还有哪些内容可供查看。

This is called introspection, and AS3 has a limited ability to do introspection.

Here is about the best you can do,

import flash.utils.describeType;

var data:XML = (describeType(SingleEvent));
for each (var method:XML in data.factory.method) {
    trace("Name: " + method.@name);
    trace("Returns: " + method.@returnType);
    for each (var parameter:XML in method.children()) {
        trace("Parameter " + parameter.@index + ": " + parameter.@type + ", optional: " + parameter.@optional);
    }
    trace("----------------------------");
}

Unfortunately, this is the limitation and will only be able to show you methods with public accessors. You can look at the output of

print data.toXMLString()

as well, to see what else is available for viewing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文