3 Replies Latest reply on Mar 16, 2010 9:04 PM by Flex harUI

    SwfLoader cause Browser to crash when we change loaded swf multiple times..

    andre215

      Hi Everyone,

       

      I'm developing a Flex application now, and inside my application I am using SWFLoader which will be used to load other .swf file.

       

      The SWFLoader is working, but after I change the .swf file so many times(around 20 times), the application always cause the browser to crash and shutdown automatically.

      I suspect this is because of the SWFLoader. If we change the loaded swf inside SWFLoader, it won't remove the old one from memory automatically.

       

       

      This is my simple code to change the loaded swf inside SWFLoader :

       

      public var applicationLoader : SWFLoader;

       

      ...

       

      public function loadApplication(appName : String) : void {

           if(loadedApplSysManager != null) {

                var currentApplication : AppInterface = loadedApplSysManager.application as AppInterface;

                if(currentApplication != null) {

                     currentApplication.applicationStateComplete(); // do something inside small app before unload

                }

           }

       

       

           // try to set everything to null, so GarbageCollection is called ..

           applicationLoader.source = null;

           applicationLoader.load(null);

       

       

           var applicationUrl : String = applicationDict[appName];

           var urlApp : String = path + applicationUrl + "?noCache=" + version;

       

           applicationLoader.source = urlApp;

      }

       

       

       

      btw, I am also using Cairngorm command in every small application and some RSL..

       

      Has anyone ever experience the same thing and have any suggestion?

      How can we handle the SWFLoader properly, the loading and unloading process?

       

      Any suggestions will be appreciate..

       

       

      Thanks,

       

      Andre