3 Replies Latest reply on Aug 3, 2010 2:22 PM by Flex harUI

    Accessing Modules loaded through mxml


      Ok, so I am using a module approach to keep my files smaller.


      Currently I have done something like this:





      id="cwqL" url="Calendar.swf" />



      How do I access the public methods on the actual Module itself?

      There is a public method called setDataDource(ac:ArrayCollection) in the Calendar module, which I want to call and assign an ArrayCollection to from the main app.


      So how do I access it?


      Or must I load my module using ModuleLoader or ModuleManager to be able to do this??




        • 1. Re: Accessing Modules loaded through mxml
          Flex harUI Adobe Employee

          Hopefully you have defined a common interface like IDataSource.  Then you

          would use IDataSource(cwqL.child).setDataDource(...)

          1 person found this helpful
          • 2. Re: Accessing Modules loaded through mxml
            ssardar Level 1

            No I am not and I  probably need to be smacked for it


            Is there an example for common interface classes (sorry for the noob question)


            but my main question is really to try to understand the best way to load a module and set it's properties from the main app (sounds simple you would think)



            This is what I have



            private function initApp():void











            public function createModule(m:ModuleLoader, s:String):void {


            if (!m.url) {

            m.url = s;







            //<--the part below does not seem to work-->


            var testclass:childtest = (m.child as childtest);









            <mx:Panel id="p2">


            <mx:ModuleLoader id="imageModuleLoader" height="200" width="1000"/>





            If I set the height and width in the mxml tag it seems to work.  But the AS code snippet doesn't.  And I would really rather do it the most efficient way.

            Please help if you can.

            (I'm very certain it's my general understanding of the Module class and I am reading on as we speak)



            harUI, I am looking up using common interfaces also.    

            • 3. Re: Accessing Modules loaded through mxml
              Flex harUI Adobe Employee

              If all you are doing is setting styles, width  & height, you don't need an

              interface.  Use UIComponent or some common base class instead.  If you use

              the main class in the module you defeat the purpose of modules.  There is a

              presentation and examples on modules on my blog


              Alex Harui

              Flex SDK Team

              Adobe System, Inc.