A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [HELP!] Load Unload External SWFs slowing down main flash

  1. #1
    Among the struggles of AS2
    Join Date
    Dec 2009
    Posts
    3

    Unhappy [HELP!] Load Unload External SWFs slowing down main flash

    I have written a basic piece of code to load and unload different swfs, now on their own they're pretty smooth (opened independently) , but when you load and unload them a couple of times in the main fla, just like as a user would navigate through a website, it causes the whole flash player and the movies to slow down quite dramatically and looks very bad as if about to crash. Now i know this problem was reported in FP 9, but anyone else has encountered this in FP 10 as well ?

    Here's how i load and unload the external SWFs using buttons :

    Code:
    bt1.addEventListener(MouseEvent.CLICK,onLoadClick);
    
    function onLoadClick(evt:MouseEvent):void
    {
    	var swfLoader:Loader = Loader(loadmc.getChildAt(0));
    	swfLoader.unload();
    	
    	var bgURL:URLRequest = new URLRequest("experience.swf");
    	swfLoader.load(bgURL);
    	TweenLite.to(loadmc, 0.8, {autoAlpha:1, ease:Sine.easeIn});
    }
    Has anyone else come across this problem and what was the workaround?

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    you're experiencing a memory leak. this is either because of large number of references aren't being cleaned up, or more likely you have a bunch of event listeners that aren't being removed.

    the long answer would be to go through each loaded swiff and make sure all references and listeners are removed when it's unloaded.

    if you don't mind targetting Player 10 only, there's a method called unloadAndStop that'll do all this for you.

    PHP Code:
    swfLoader.unloadAndStop(); 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center