6 Replies Latest reply on Dec 1, 2010 8:48 AM by darren.y.ng

    PopUpManager

    darren.y.ng

      Hi,

       

      I have an issue using PopUpManager in my application. From the information I've read on various forums and websites, I believe the problem is that the parent application (that loads my application) has an instance of PopUpManager already and when I try to use PopUpManager in my child application, the swfBridge between the two applications has not been established and therefore my child application cannot access PopUpManager.

       

      So... I think I understand the problem, but I don't know how to get to the solution. Is there a way, without changing the parent application, to use PopUpManager in my child application?

       

      Specifically, I call PopUpManager.addPopUp and get an error in SystemManager.addPopupRequestHandler of the parent application, because the swfBridge is null.

       

      Any help would be greatly appreciated.

       

      Thanks,

       

      darren

        • 1. Re: PopUpManager
          Flex harUI Adobe Employee

          Use a link-report to make sure PopUpManager is linked into the main app.  If

          it isn't, use:

           

              import mx.managers.PopUpManager; PopUpManager;

           

          to force link it.

           

          If you are using Flex 4, make sure both apps

          -includes=mx.managers.systemClasses.MarshallingSupport

          1 person found this helpful
          • 2. Re: PopUpManager
            darren.y.ng Level 1

            Hi,

             

            Thanks for the prompt reply!

             

            I checked link-report and PopUpManager is in the list of dependencies. Even so, I added the line you suggested to force linkage. Unfortunately this didn't correct the issue. Maybe I'm mis-characterizing the problem.

             

            I have the parent application (let's say ParentApplication.swf). ParentApplication loads my application (ChildApplication.swf) and the two applications communicate via LocalConnections (not sure if this is important).

             

            ParentApplication has pop ups for warning messages and other things like that. In ChildApplication, I'd like to throw up a pop up, but this is where I'm getting the null reference for swfBridgeGroup in SystemManager's addPopupRequest. I can see that the target member in the event that gets passed into addPopupRequestHandler is populated with the ParentApplication's SystemManager. So, it appears that even though I am calling PopUpManager.addPopUp from ChildApplication.swf, it still goes through ParentApplication.

             

            I'd rather not have to change ParentApplication, as I don't own the source code for that. But if necessary, I can have changes made in there as well.

             

            Interestingly, I originally developed the ChildApplication pop up using the Flex 4 SDK in ChildApplication (with ParentApplication still built with 3.4) and everything was working (without having to make any compiler argument changes). However, after downgrading ChildApplication to Flex 3.4, these issues are popping up -- no pun intended.

             

            Thanks again,

             

            darren

            • 3. Re: PopUpManager
              Flex harUI Adobe Employee

              Let's make sure we have all the facts:

               

              ParentApplication.swf:

              -built in Flex 3.4

              -has link-report with PopUpManager in it

               

              ChildApplication.swf

              -built in Flex 3.4

              -has link-report with PopUpManager in it

               

              Is this correct?  Are both SWFs in the same domain?  What parameters are

              used in the SWFLoader of the main app?  What is the exact text of the error

              and stack trace?

              • 4. Re: PopUpManager
                darren.y.ng Level 1

                I've decided on a workaround... I am going to just take the TitleWindow containing the pop up and add it as a child to my top most sprite, and then use startDrag/stopDrag to give it the "pop up" behavior. I suppose there is nothing that I specifically need a pop up for.

                 

                That being said, I'd still like figure out what's going on. But please don't give yourself a headache over this...

                 

                Your summary is correct. This is exactly how the applications are built.

                 

                The ChildApplication is loaded into its own ApplicationDomain by the ParentApplication. The SWFLoader in ParentApp is passed a LoaderContext with a new ApplicationDomain() -- ie. not parented to current ApplicationDomain.

                 

                Here is the call stack from the null reference. FlashFramework is a set of classes that the ChildApplication is built upon. The DemoMenu is essentially a set of buttons that trigger different things in the ChildApplication (one of which is popping up a TitleWindow)

                TypeError: Error #1009: Cannot access a property or method of a null object reference.

                at mx.managers::SystemManager/addPopupRequestHandler()[C:\autobuild\galaga\frameworks\projec ts\framework\src\mx\managers\SystemManager.as:3769]

                at flash.events::EventDispatcher/dispatchEventFunction()

                at flash.events::EventDispatcher/dispatchEvent()

                at mx.managers::PopUpManagerImpl/addPopUp()

                at mx.managers::PopUpManager$/addPopUp()

                at framework.game::Game/OnDemoRequest()[C:\online\Client\FlashFramework\framework\game\Game. as:995]

                at flash.events::EventDispatcher/dispatchEventFunction()

                at flash.events::EventDispatcher/dispatchEvent()

                at framework.debug.demo::DemoMenu/OnDemoRequestEvent()[C:\online\Client\FlashFramework\frame work\debug\demo\DemoMenu.as:225]

                at flash.events::EventDispatcher/dispatchEventFunction()

                at flash.events::EventDispatcher/dispatchEvent()

                at mx.core::UIComponent/dispatchEvent()

                at framework.debug.demo::DemoMenuDisplay/OnFeatureListDoubleClick()[C:\online\Client\FlashFr amework\framework\debug\demo\DemoMenuDisplay.mxml:217]

                at framework.debug.demo::DemoMenuDisplay/__featureList_itemDoubleClick()[C:\online\Client\Fl ashFramework\framework\debug\demo\DemoMenuDisplay.mxml:20]

                at flash.events::EventDispatcher/dispatchEventFunction()

                at flash.events::EventDispatcher/dispatchEvent()

                at mx.core::UIComponent/dispatchEvent()

                at mx.controls.listClasses::ListBase/mouseDoubleClickHandler()

                • 5. Re: PopUpManager
                  Flex harUI Adobe Employee

                  In the SystemManager's initHandler, there is a call to useSWFBridge.  When

                  the child app loads, it should return true and set up the swfBridgeGroup.

                  Then it should dispatch a BRIDGE_NEW_APPLICATION event which should be

                  picked up by the SWFLoader in the main app and result in a call to

                  addChildBridge that should set up the main app's swfBridgeGroup.

                   

                  See if you can debug in and how far you get.

                  1 person found this helpful
                  • 6. Re: PopUpManager
                    darren.y.ng Level 1

                    After debugging the ParentApplication further, it turns out that I was incorrect. The ParentApplication uses flash.display.Loader to load the ChildApplication. I guess this is the root issue.

                     

                    Unfortunately, I don't own the ParentApplication code, though I could request a change to it. I think the biggest problem is that the Loader is passed around to a lot of different parts of the ParentApplication code, so changing it to a SWFLoader isn't necessarily an easy operation.

                     

                    Thanks for pointing me in the right direction!