6 Replies Latest reply on Feb 26, 2007 12:22 PM by france2003

    Referencing Applications

    Ukie_239
      I have a main application that loads another application inside it. (Basically a parent->child relation) Can the other application reference objects in the main application?

      In a nutshell, the main application is my menu and status bar. This menu loads a specific application when needed.
        • 1. Re: Referencing Applications
          peterent Level 2
          In a nutshell, yes. You should read the documentation on ApplicationDomain - there are several ways to go with it so you should read about and then decide. Much of it has to do with security, but also how classes and definitions are shared.
          • 2. Re: Referencing Applications
            Ukie_239 Level 1
            Is there a good example of a parent application loading a child application and the child application referencing a object in the parent application? I can find the other way around, and I don't understand 100% the documentation. I really need to get his figured out to move forward :(

            Thanks
            • 3. Re: Referencing Applications
              france2003
              Hey Ukie [or anyone], did you ever find a good example of a parent app loading a child app and the child app referencing an object in the parent app? I am in great need of this right now.
              • 4. Re: Referencing Applications
                jlingwai Level 1
                Ukie,

                Let me see if i get your question...... You have a flex application and with in that application you are loading a .swf of another flex applicaiton into it.......and you want to comunicate between the both of them.....if this is correct i did this by using flash.net.LocalConnection

                -JoSh
                • 5. Re: Referencing Applications
                  peterent Level 2
                  If the SWF you are loading is also an ActionScript 3 SWF (eg, built for Flex 2) then you can access the contents (variables and functions) directly - but only if they are in the same security sandbox.

                  Suppose you have loaded the second app using the SWFLoader named app2. When that has completed loading (it will dispatch an Event.COMPLETE event), the second application is available using the content property of the app2. The content should be of type SystemManager and it has an application property which can be cast to the class of the second application (eg, MyApp2 if that app's main file was MyApp2.mxml).

                  Caveat: I'm writing this from memory so you may have to look up some of these things in case I'm mis-remembering. But you can do it, it was designed to be done.

                  If you are loading an ActionScript 2 SWF, then you have to use LocalConnection.

                  For Flex 2, you might consider using Modules instead of SWFLoader because Modules are easier to use. I have an example on my blog.

                  • 6. Re: Referencing Applications
                    france2003 Level 1
                    Thank you, Peter! I have begun to implement modules and it is working out wonderfully! Thanks again!