9 Replies Latest reply on Nov 4, 2010 2:17 PM by Flex harUI

    SWFLoader Problem

    bistro37
      I'm using Flex 3.2 and Flash 10 and trying to load sub-applications using the SWFLoader. But if I don't add the SWFLoader to a Container or something that is already in the main application before actually trying to load the sub-application, I get a nullpointer:

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at mx.controls::SWFLoader/initSystemManagerCompleteEventHandler()[C:\autobuild\3.2.0\framewo rks\projects\framework\src\mx\controls\SWFLoader.as:2174]
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at mx.managers::SystemManager/initHandler()[C:\autobuild\3.2.0\frameworks\projects\framework \src\mx\managers\SystemManager.as:2862]

      I don't want to add the SWFLoader to the stage until it actually has completely loaded. I have attached a sample application that is doing the same thing. It contains two sub-applications and one main application. There are comments in SubAppPrototype.mxml that point out the problem.
        • 1. Re: SWFLoader Problem
          ntsiii Level 3
          First, you say, "I don't want to add the SWFLoader to the stage until it actually has completely loaded".

          Why do you have that constraint? What are you trying to accomplish?

          Tracy
          • 2. Re: SWFLoader Problem
            bistro37 Level 1
            I actually ran into other problems when doing it the other way. The sample application is much smaller than the real application and in the real application I was having problems with events not being received and components not actually rendering. So it was easier to just wait for the loader to be done and then add the resulting application to the stage.
            • 3. Re: SWFLoader Problem
              ntsiii Level 3
              Continue that way if you insist, but you are introducing complexity to solve what may be a simpler problem

              Application size is not significant.

              When working with SWFLoader, one typical problem is that even though the loader is rendered and complete, the application it contains is not yet complete. So communicating with an app loaded by SWFloader requires a two-step event-listening process.

              Look over this example:
              http://www.cflex.net/showFileDetails.cfm?ObjectID=690

              Tracy
              • 4. Re: SWFLoader Problem
                bistro37 Level 1
                You're right but unfortunately I have to use applications because I have to support pluggable components (some third-party) and they will be built on different versions of Flex. I have already figured out the communication between the applications and how to determine when the application is fully loaded. My problem is once fully loaded there still seems to be some information not set correct (such as the parent or top level System Manager).
                • 5. Re: SWFLoader Problem
                  ntsiii Level 3
                  "...unfortunately I have to use applications ..." You misunderstood something. I did not say not to use applications.

                  Make up your mind about the problem. Which is it?
                  "...problems with events not being received and components not actually rendering..."
                  or
                  "...some information not set correct (such as the parent or top level System Manager..."

                  Tracy
                  • 6. Re: SWFLoader Problem
                    bistro37 Level 1
                    I have gotten past the event/completion/rendering problems. The real problem is the System Manager problem. That is what was causing the original error that I posted.
                    • 7. Re: SWFLoader Problem
                      ntsiii Level 3
                      But you are back to trying to manipulate the SWFLoader before putting it on the displayList. Which I think is unnecessary complication.

                      Once around the circle is enough for me. Maybe someone else can help.

                      Tracy
                      • 8. Re: SWFLoader Problem
                        frankz00 Level 1

                        Geez... I think "I don't know" would have sufficed...

                        • 9. Re: SWFLoader Problem
                          Flex harUI Adobe Employee

                          Flex requires that SWFLoaders be on the display list when loading other Flex

                          SWFs.  You can make them visible=false  and/or includeInLayout=false, or

                          shove them where they will be clipped, but they have to be on the display

                          list.