4 Replies Latest reply on Mar 26, 2007 12:17 AM by sreekar81

    data passing between modules

    sreekar81
      Hi,

      how to access data of one module in another. I tried the below sample but itz not identifying the function in the other module.

      <?xml version="1.0"?>
      <!-- modules/TitleModuleLoader.mxml -->
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:Script>
      <![CDATA[ ]]>
      </mx:Script>
      <mx:ModuleLoader url="InterModule1.swf" id="m1"/>
      <mx:ModuleLoader url="InterModule2.swf" id="m2"/>
      </mx:Application>

      Module 1:<?xml version="1.0"?>
      <!-- modules/InterModule1.mxml -->
      <mx:Module xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" height="100%">
      <mx:Script>
      <![CDATA[
      // Defines the method that the other module calls.
      public function getNewTitle():String {
      return "New Module Title";
      } ]]>
      </mx:Script>
      </mx:Module>

      Module 2:
      <?xml version="1.0"?>
      <!-- modules/InterModule2.mxml -->
      <mx:Module xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" height="100%">
      <mx:Script>
      <![CDATA[
      [Bindable]
      private var title:String;// Call method of another module.
      private function changeTitle():void
      {title = parentApplication.m1.child.getNewTitle();}
      ]]>
      </mx:Script>
      <mx:HBox>
      <mx:Label id="l1" text="Title: "/>
      <mx:Label id="myTitle" text="{title}"/>
      </mx:HBox><mx:Button id="b1" label="Change Title" click="changeTitle()"/>
      </mx:Module>

      Please guide me....
        • 1. Re: data passing between modules
          Gboro54
          you know i was goin to ask something similar to you... I wanted to know if it is possible for two modules to communicate between each other...(i.e if mod1 has a text area and it changes then the title of a data grid in mod2 would change...this is a bad example though)

          • 2. Re: data passing between modules
            Gboro54 Level 1
            I think if i am not mistaken( i could be) that you should be seting
            title= parentApplication.child.m1.getnew Title();...i could be wrong though
            • 3. Re: data passing between modules
              sreekar81 Level 1
              No my friend... I even tried that too.... but to no use.....
              • 4. data passing between modules
                sreekar81 Level 1
                I have a main application and two modules. The first module shows the id's of employees. so, if I select an empid and press edit button, another module will be loaded and it will display the details of the employee who is selected in the first module. But I am unable to access the empid in the second module.. It is giving an error like:

                ReferenceError: Error #1069: Property getNewTitle not found on EmpModify and there is no default value.
                at EmpModify/::changeTitle()
                at EmpModify/__b1_click()

                getNewTitle is the function of first module.
                EmpModify is the name of second module.

                Please help me with this?????