5 Replies Latest reply on Feb 7, 2008 9:55 AM by Darrell Loverin

    ModuleManager/Loader and interfacing with modules

      I have a module that creates an object and then sets a few attributes of that object all in the modules OnLoad() event. When I load the module, either in a moduleloader or modulemanager, and attempt to interface with the module, all the object attributes that should be have been set in the modules oncreate are nill. However, If I call a method in the module to reinitialize my object then the values are assigned when I inspect them.

      I have traced through the on create and the values are being set when the module is loaded.
        • 1. Re: ModuleManager/Loader and interfacing with modules
          Darrell Loverin Level 4
          Could you provide more details about what you mean by "attempt to interface with the module".
          I don't see an "OnLoad()" event on modules. Do you mean the "ready" event defined in the ModuleEvent class?
          • 2. ModuleManager/Loader and interfacing with modules
            SonOfGerale Level 1
            Sorry about the confusion. I am using the modules's creationComplete event inside the module's mxml file to create and load default values in an object - the object I want to be able to access in the main application.

            In the main application I want to first display the module in a box and second get a reference to the object created inside the modules creationComplete() event. I am using the IModuleInfo interface to reference the module and it's attributes, specifically my custom objects. I will give a short example.

            • 3. Re: ModuleManager/Loader and interfacing with modules
              Darrell Loverin Level 4
              After creating the module, listen for the "creationComplete" on the object so you know the module is done processing the code you put on the "creationComplete" handler in the module.

              public function PerformOnNewReport(e:Event):void {
              ReportInterface=IReport.factory.create() as Object;
              vbReportViewer.addChild(ReportInterface as DisplayObject);
              var RI:ReportInfo=ReportInterface.GetReportInfo();
              tiTest.text=RI.ReportTitle; //<--ALWAYS NULL

              ReportInterface.addEventListener("creationComplete", moduleCreationCompleteHandler);

              private function moduleCreationComplete(event:Event):void
              tiTest.text=RI.ReportTitle // value should be set
              • 4. ModuleManager/Loader and interfacing with modules
                SonOfGerale Level 1
                Thanks Darrell
                I will give that a try. It seems a bit odd that the ModuleManager's "ready" function is firing before the modules creationComplete event completes. I guess it just goes to show how much I have to learn. By the way, I like the debugger, and especially the ability to step into core library packages during execution. When I saw that I was like wow!, nice feature to have.

                Now this may be a long shot, but I was going to ask the top of your head if it would be possible to:

                Descend from module in an mxml file and call the new class A.
                Descend from A as a new class B
                Have all my new module of type B

                Think the above would break the module framework but it would be nice.
                Don’t think a dynamic list of modules would work without me having to write allot of code,
                Basically some sort of frame, form, or module that can be descended from two times and is not tightly linked in the application and could possibly be used by other applications like COM did. Would work
                • 5. Re: ModuleManager/Loader and interfacing with modules
                  Darrell Loverin Level 4
                  I think you'll be able to create the subclasses of the module you want. The name of a module's mxml file is the name of the class. For example, a module named fooModule.mxml, has a class name of fooModule. To subclass fooModule create a file barModule.mxml that uses:

                  <local:fooModule xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns:local="*" width="400" height="300" >

                  instead of <mx:Module> as the root element.