Help with Introspection using ActionScript 3

Brian LeGros | April 12th, 2008 | programming  

Ok, I need help. I’ve been able to discover the coolness that is getQualifiedClassName() and getDefinitionByName() and describeType() when it comes to working with introspection/reflection in ActionScript 3. I am stuck however. I want to get a hold of all the class names available in the compiled Flash movie at runtime. I’m writing a library that will look for custom metadata on classes and associate functionality with the classes (or possibly objects) if they are annotated in a specific way. Right now, short of asking for a list of those classes from the developer, I don’t know of a way to build a bootstrap function/class that will introspection into the Flash movie and get me a list of them. I was thinking maybe if I could find a way to programmatically access the manifest file that would work, but again I can’t find a way to do that.

Does anyone know how to do this or am I doomed to introspecting on objects and programmer declared references rather than classes?

UPDATE: I found a feature request in the Flex 3 JIRA database. Basically it’s not in Flex yet, nor is it supported by the Flash movie, but 4 people have voted for the feature thus far. That being said, please vote for this feature so we can get one of the final pieces to reflection built into Flex. BTW - If anyone wants questions answered with regards to Flex, check out the flexcoders mailing list over on Yahoo. Everyone probably knows about it but I’m slow.



Tags: , , ,

Related posts

Discussion

  1. julien Says:

    You should also check
    http://lab.kapit.fr/display/kapinspect/Kap+Inspect

    It is a free tool that I developed, and that will allow you to inspect any Flex application.

    Julien

  2. Brian LeGros Says:

    @julien - Thanks for stopping by. In this post I was referring more to programmatic introspection on ActionScript classes, rather than manually inspecting my Flex application. That being said, it looks like y’all are making a lot of cool tools and components over at Kapit, so keep up the great work and thanks for the link.

  3. Julien Says:

    Hi Brian, I did not mean to disturb you, sorry if I did.
    Meanwhile, I discovered another library that does exactly what you are looking for: reading all classes from a SWF or from loadedBytes of your application :
    http://dev.etcs.ru
    It is written in Russian , and you have to find out the ClassExplorer application and get the source code (I founded it in the getDefinitionNames Jira Post you talk about)
    I tried it, it works fine : it gives you an XML with all definitions of the SWF, comprising private and protected members (you dont get them through describeType), and even internal classes.
    I did not check for all namespaces.
    If you dont find sources in the russian blog, send me a mail, I’ll send them back to you directly
    Julien

  4. Brian LeGros Says:

    @Julien - Ah no worries man, I appreciate all of the insight you’ve passed along; it’s been a great help. The getDefinitionNames() method is an awesome find. This is exactly what I was looking for. I found the source code here after translating the site. Thanks again for all your help man. You rock!

Add A Comment