views:

67

answers:

2

How do I get the list of all methods from an object? I know I can get the object class in this way:

var className:String = flash.utils.getQualifiedClassName( myObject );
var objClass:Class = flash.utils.getDefinitionByName( className ) as Class;

It gives me an the class prototype, but and can't do anything with it... In JavaScript I can iterate over the prototype of an object to get its properties and methods.
Is that possible in ActionScript 3? Do you any good source for metaprogramming/reflection over ActionScript 3?

Thanks!

+4  A: 

Check out the describeType function.

Juan Pablo Califano
Thanks, but I need a way to call the methods. This decribeType just serializes the object into XML.
Eduardo Cobuci
@Eduardo. Yes, but if you have the object and you have the name of the method, you can call it. With the same syntax as in JS: `object[method](parameter);`.
Juan Pablo Califano
The XML part is a little ugly but it works. Thanks
Eduardo Cobuci
A: 

Have you tried using the operators (for ... in...) once you got the Class reference or the Object instance? It should work.

Alex Nino
That will only work for dynamic properties.
Juan Pablo Califano