Skip to main content
November 16, 2010
Answered

Too much delay to load new SWF after unloaded the current SWF

  • November 16, 2010
  • 1 reply
  • 873 views

Hi,

In our application we are using more than 10 SWFs. While traversing one SWF to other trying to unload currently loaded SWF and loading the new one. We were success to unload the existing SWF but the problem is, taking too much time to load new SWF (more than 5 seconds). Please suggest a useful method to avoid this delay to get better performance.

will get some idea from following code snippet.

Thanks


public function SwitchSWFs():void

{

               if (null != SystemAgent.getInstance().currentSWFLoader)

                {
                                SystemAgent.getInstance().currentSWFLoader.unload();
                                SystemAgent.getInstance().currentSWFLoader = null;
                                trace("HomeUI : Previous swf unloaded!!!");
                }
                else
                {

                }
                addChild(SystemAgent.getInstance().swfLoaderSecondSWF);
                SystemAgent.getInstance().currentSWFLoader = SystemAgent.getInstance().swfLoaderSecondSWF;

}


//will invoke from a button click
public function LoadSecondSWF():void

{
                SystemAgent.getInstance().swfLoaderSecondSWF.load(new URLRequest("Second.SWF"));
                SwitchSWFs();

}

This topic has been closed for replies.
Correct answer Ned Murphy

Is the delay happening when you test locally?

One thing you might try is to load any Loaders you have up front before they are needed so that there is a better chance they are ready to be added to the display list when called for.  So instead of having the button trigger loading the swf, you just have it call the switchSWFs function.

Another thing you might try if you keep it where the button triggers loading the file is to assign an event listener for the Loader to detect when it has finished loading and then have that listener's event handler function call the switchSWFs function.  At least that way, the current swf is not unloaded until a replacement is ready and waiting.

1 reply

Ned Murphy
Legend
November 16, 2010

How large is the second file?

November 16, 2010

Thanks for your Response.

First file is 99 KB and second file is 702KB.

Please advise

Ned Murphy
Ned MurphyCorrect answer
Legend
November 16, 2010

Is the delay happening when you test locally?

One thing you might try is to load any Loaders you have up front before they are needed so that there is a better chance they are ready to be added to the display list when called for.  So instead of having the button trigger loading the swf, you just have it call the switchSWFs function.

Another thing you might try if you keep it where the button triggers loading the file is to assign an event listener for the Loader to detect when it has finished loading and then have that listener's event handler function call the switchSWFs function.  At least that way, the current swf is not unloaded until a replacement is ready and waiting.