7 Replies Latest reply on Sep 17, 2010 1:45 PM by BlackenedBR

    Help needed with mx Modules...


      Hello guys!


      So, here´s the deal.... i have developed  a little application using flex which works just fine. I made some  stress tests an didn´t had any kind of failure.


      Then, i  decide to modularize my application.... i created a new application  (type <mx:Application> ) and transformed the old application into a  module (<mx:Module>) . Let´s calll this ModuleOne.


      I used as a basis for the development an example that  exists at the adobe site regarding ModuleLoader. (   http://livedocs.adobe.com/flex/3/html/modular_6.html#170736   )


      So,  now i have my Application, the ModuleLoader and my Modules. I have  created another module (ModuleTwo) in order to test and make some  troubleshooting.


      And now gets tricky. When i load ModuleOne, he works  fine, no problems... just like his old application type used to work.  When i load the ModuleTwo, he wors fine also. When i try to come back to  ModuleOne, loading it once again, the problems come.


      After  this second time load of ModuleOne, he doesn´t filll the ComboBoxes  with my database data. The clock cursor keeps running, as if he is  waiting for something... on my point of view, he is waiting for the  comboboxes to get filled.


      I read on several websites  that Modules sometimes don´t get unloaded or garbage collected due to  some references problems of Flex itself. Unfortunately, i´m not any kind  of pro. I´m still learning and trying to get things done.


      If you see the ModuleLoader webpage at adobe, you´ll se the exact code that i use to load, unload and reload the Modules.

      Below, i´ll post the code.


      I thank very much anyone for any help!





      Application Code


      <?xml version="1.0"?>
      <!-- modules/General.mxml -->
      <mx:Application xmlns="*" xmlns:mx="http://www.adobe.com/2006/mxml"  width="1020" height="644" layout="absolute" backgroundColor="#ffffff"  verticalScrollPolicy="off" horizontalScrollPolicy="off">
                   import mx.effects.easing.*;
                   import mx.modules.*;
                   public var selectedItem:Object;

          <mx:Object id="FormObj" label="Mapa" module="Form.swf"/>
           <mx:Object id="NewObj" label="News" module="News.swf"/>

            <mx:Button id="FormButton" label="Form" click="selectedItem=FormObj"  x="12.5" y="504" width="157.5" height="90" cornerRadius="20"  mouseUpEffect="bounceEffect"/>
            <mx:Button id="NewsButton" label="News"  click="selectedItem=NewObj" x="11.25" y="210" width="157.5" height="90"  cornerRadius="20" />
            <CustomModuleLoader id="mod" width="100%" height="100%" url="{selectedItem.module}" />





      ModuleOne code


      <mx:Module  xmlns:mx="http://www.adobe.com/2006/mxml" paddingBottom="0"  layout="absolute" backgroundColor="#ffffff" initialize="{init()}"  width="820" height="584" dropShadowEnabled="false">

          <mx:Script source="Filler.as" />

              <mx:Text x="10" y="151" text="Form" fontWeight="normal"/>
               <mx:ComboBox x="10" y="167" width="134" id="Field01" labelField="name" />



      ModuleLoader code


      Just like from Adobe site: http://livedocs.adobe.com/flex/3/html/modular_6.html#170736

        • 1. Re: Help needed with mx Modules...
          Flex harUI Adobe Employee

          What does filler.as look like?

          • 2. Re: Help needed with mx Modules...
            BlackenedBR Level 1

            Hello harUI, thanks for your reply.


            As you will see below, the filler.as is an actionscript which uses Remote Objects. The JAVARemote is a class which implents the Remote Objects from Flex. I can successfully use it for the first time it runs. For the second (case i unload and reload the module), it doesn´t fill the dropbox, and the clock cursor runs forever...


            I have tried to use the functions disconnect and logout from the Remote Objects, but it doesn´t solved the problem.


            For your information, i´m using Flex <-> BlazeDS <-> Java.


            The Java class simply access the database and retrieve the results back to Flex, through the Remote Objects use.


            Well, the filler.as looks something like this:


            import ConnectRO.JAVARemote;


            import mx.collections.*;
            import mx.controls.Alert;
            import mx.controls.*;
            import mx.rpc.events.ResultEvent;

                private var JavaRemote:JAVARemote = new JAVARemote();


                // Initialization function, fill dropbox.
                public function init():void{
                    JavaRemote.destination = "Database.Connect";


                public function onResultField01(re:ResultEvent):void
                       var data:Object = re.message.body;       
                    Field01.dataProvider = data;


            Thank you very much for your help!

            • 3. Re: Help needed with mx Modules...
              Flex harUI Adobe Employee

              The problem might be in JAVARemote class.  You should contact the people who

              wrote it to see if they have known issues with modules.


              In general, you have to be careful with RemoteObjects in child

              applicationDomains.  You might want to be sure you are using FP 10.1 as some

              bugs got fixed in there.

              • 4. Re: Help needed with mx Modules...
                BlackenedBR Level 1

                Hello harUI,


                well, i´m using Flex Builder 3 with Eclipse for the development.... and there is something weird....


                for my Internet Browser, the Flash Player version 10.1 is been used... but when i run the swf as stand-alone, the screen says it is running in Flash Player 9... do you have any tip about this?


                Regarding the JavaRemote.as file, he is as described below....


                As you can see, the "clock cursor running forever" seems happen on the function JAVARemote... since the cursor gets stuck after the module reload...


                After some test, i found some more weird thigs.... when the alert.show("Constructor") is on (not commented), the cursor don´t get stuck, but neither the combobox is filled... i have no idea what i´m facing here... i´m kind of desperate to find out what´s the issue....




                package ConnectRO {


                    import mx.controls.Alert;
                    import mx.rpc.AsyncToken;
                    import mx.rpc.Responder;
                    import mx.rpc.events.FaultEvent;
                    import mx.rpc.remoting.mxml.RemoteObject;


                    //Class used to perfome remote calls to the java classes methods.
                    public class JAVARemote extends RemoteObject {
                        public function JAVARemote(){
                            this.showBusyCursor = true;
                        public function get getConnection():RemoteObject {
                            return this;
                        public function call(Method:AsyncToken, NewResult:Function):void {
                            var L_Async:AsyncToken;
                            L_Async = Method;
                            L_Async.addResponder (new Responder(NewResult, DefaultFaultHandler));
                        private function DefaultFaultHandler (Result:FaultEvent):void {
                            Alert.show(Result.fault.faultString, "Error");


                    }// ActionScript file

                • 5. Re: Help needed with mx Modules...
                  Flex harUI Adobe Employee

                  If you are on Windows, you may be running the standalone player when

                  launching SWFs.  You will need a later one.  Should be in the SDK folder

                  under 4.0.0/in/player/10.1/win


                  One solution to try is to put JavaRemote and the data classes in the main

                  app as well as the module.

                  1 person found this helpful
                  • 6. Re: Help needed with mx Modules...
                    BlackenedBR Level 1

                    Hello harUI,


                    well, thanks anyway for your help. I have tried what you suggested, but it didn´t worked out.


                    After keep trying, it seems that i have found a solution. I have no idea with it is working, but my application works as expected...


                    If anyone faces this issue in the future, what have worked for me is the following:


                    in the main Application, the script code has the following lines:



                    // ActionScript file


                                import mx.effects.easing.*;
                                import mx.modules.*;
                                import mx.collections.*;
                                import mx.controls.*;
                                import mx.rpc.AsyncToken;
                                import mx.rpc.Responder;
                                import mx.rpc.events.*;
                                import mx.rpc.remoting.mxml.RemoteObject;
                                import mx.managers.*;
                                public var selectedItem:Object;
                                private var dragManager:DragManager;
                                private var popUpManager:PopUpManager;
                                private var iPopUpManager:IPopUpManager;
                                private var iModuleLoader:ModuleLoader;
                                 protected var _moduleInfo:IModuleInfo;


                        //Remote object used to execute java requests at server regarding Connection class.
                        private var JavaRemote:RemoteObject = new RemoteObject();



                    if i remove the RemoteObject declared, the application stops to work, show some coercion fails and messages of problems with the iMessage** (* stands for something)...


                    Anyway, thanks very much harUI.... despite your suggestion didn´t worked out, it helped me in other ways to find a way to get my app running with the modules....


                    Luck to all! Success!



                    • 7. Re: Help needed with mx Modules...
                      BlackenedBR Level 1



                      i forgot to mention something: as i uploaded my flash plugin to version 10, my internet browser started to take a long time to finish, after i click on the X (to close) when i run a flex application....


                      sometimes it even stopped to respond.... and needed to be finished through task manager...


                      as i downgraded the version back to 9, it worked on again as usual, without delays...


                      something to look after ; )