7 Replies Latest reply on Aug 10, 2010 8:03 AM by Flex harUI

    Load Flex application into Flash application

    tsgsp

      Greetings,

       


      Has anyone ever loaded a Flex application into a Flash application and been able to interact with both applications simultaneously? Some of my clients use either Flex or Flash to develop their applications. In either case, their applications include a few lines of code to DL my custom swf which while developed in Flex Builder didn't really have any dependencies on the Flex framework and thus works perfectly. However, I will need to start adding UI elements and that has proved tricky. If the client's application was developed with Flex then everything is fine. However, if the client application isn't a Flex application issues arise. At first, the application would crash once it loaded my SWF. Foruntately I was able to work around that (By listening for the events "mx.managers.SystemManager.isBootstrapRoot" and "mx.managers.SystemManager.isStageRoot" and calling "event.preventDefault()" in both cases.") However, what winds up happening is that my Flex application is loaded on top of the client application which the user can no longer interact with. Only when I remove the Flex app from the stage does the Flash app regain interactivity. Is what I'm trying to do even possible?

       


      Thanks,
      tsgsp

        • 1. Re: Load Flex application into Flash application
          Flex harUI Adobe Employee

          If the flash app uses the fl.* classes, there is a good chance it won't

          work, unless you sandbox the Flex SWF, which will be a lot of work.

           

          Flex does not support being loaded into a Flash app, but several folks do

          have it working.

          • 2. Re: Load Flex application into Flash application
            tsgsp Level 1

            I don't (and won't) know what classes the client applications use, unfortunately.

             

            As I mentioned in my first post, I am able to successfully load the Flex swf onto the stage, and it runs. The only "problem" is that it takes over focus, and the client application can't be interacted with until the SystemManger of the Flex app is removed from the stage, at which point the client app regains focus and works fine. I was digging into the SystemManager code but there's quite a lot going on, and since I can't seem to attach my debugger and step through the code, it's hard to really know what's going on.

             

            How are the other folks getting it to work?

             

            Thanks.

            • 3. Re: Load Flex application into Flash application
              Flex harUI Adobe Employee

              There aren't other interactive controls in their Flash apps.  The Flash apps

              are shells to do fancy preloading.

              • 4. Re: Load Flex application into Flash application
                tsgsp Level 1

                I'm not sure I follow you. The client applications are full blown applications developed in Flash (perhaps even pure AS3?) Most of the time I have to decompile them to see any code, so I don't know much about what goes on in them. Additionally, I'm primarily a Flex developer.

                 

                The library of mine that these client apps download at runtime is additional functionality that is completely separate from the functionality of the client's application.

                • 5. Re: Load Flex application into Flash application
                  Flex harUI Adobe Employee

                  I was trying to make the point that most folks who have Flash apps load Flex

                  don't do much in the Flash app.  You're in unsupported territory, so it

                  isn't clear how well things are going to work.

                   

                  You can try sandboxing.  Load the Flex SWF from a different domain than the

                  Flash SWFs and the Flex SWF might run on its own.  See the Marshall Plan

                  documentation for more details.  It still may not work though.

                  • 6. Re: Load Flex application into Flash application
                    tsgsp Level 1

                    I see what you mean now. I will look into the Marhsall Plan.

                     

                    I just wanted to clarify: the Flex app is being loaded successfully and runs fine (it is being served from a different domain and we have crossdomain.xml to keep everything happy.) Additionally, I can pass objects and call methods between the Flash and Flex code. So, everything is working. The "problem" is that when the Flex app is loaded it's essentially layered on top of the Flash app and while the Flash app is still running (animations still happen, etc...) it isn't possible to interact with it until the Flex app is removed from the stage. From what I can tell the SystemManager is "at fault" as it creates a sprite that acts as a mouse catcher that is the full height and width of the Flash app. I've looked at the code for SystemManager, but it's pretty complicted, and again, I can't debug and step through to see what's actually going on. Sorry for saying all this again, I just wanted to make sure we were on the same page. Additionally, thanks for all your assistance thus far. As I'm defintely in unsupported territory finding any help has been quite difficult.

                    • 7. Re: Load Flex application into Flash application
                      Flex harUI Adobe Employee

                      Well, the layering issue may be the one you know of now, but I still would

                      expect other problems in other host apps later.  Often there are problems

                      when you hit the tab key and Flash's focusManager runs code on Flex

                      components.

                       

                      Anyway, hopefully sandboxing will also solve the mousecatcher issue.