开发者

Actionscript - obtain method list for a given class name

I want to obtain a list of methods available to a c开发者_JAVA技巧lass, given its name. How can I do this?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜