2 Replies Latest reply on Oct 19, 2009 2:27 AM by riatest

    How to get class definition from a loaded module?

    riatest Level 1

      I am trying to get class definition from a loaded module using ApplicationDomain.getDefinition(). I need it to be able to instantiate an object of that class using operator new.

       

      When the module is loaded in the currentDomain of loader application everything is fine. I can get the definition using ApplicationDomain.currentDomain.getDefinition(className) call.

       

      However when the module is loaded by default (not in the loader application domain) I cannot seem to be able to get the definition no matter what I try.

       

      The ApplicationDomain.currentDomain.getDefinition(className) throws and exception. I tried getting the correct domain using child.root.loaderInfo.applicationDomain, where child is an object from the loaded module. This still does not work since it returns the same domain.

       

      What is even strange is that child.root refers to the top-most application which seems to contradict to what is written in Flex docs for "root" property:

      "For a display object in a loaded SWF file, the root property is the top-most display object in the portion of the display list's tree structure represented by that SWF file." (See http://livedocs.adobe.com/flex/3/langref/flash/display/DisplayObject.html#root)

       

      Doesn't this mean that "root" should refer to the Module in this case? If "root" refers to top-most application how do I get the correct domain given a DisplayObject from the module?

       

      Anyway, I am unable to find ANY way to get the class definition from the module using the class name. Any ideas?

       

      Full source code of minimal sample application that demonstrates the problem is attached.

       

      Thanks.