开发者

Actionscript - obtain method list for a given class name

开发者 https://www.devze.com 2023-02-01 19:10 出处:网络
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.

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

精彩评论

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