Jump to content
Search Community

SWFs not unloading

growch test
Moderator Tag

Recommended Posts

Hello,

 

I'm working on an AIR/iOS app and was having some issues with the unloading of swfs that are loaded via SWFLoader.

 

Basically, each page aka view of my app has a local reference to the class below.

 

public function SWFAssetLoader(thisSWF:String, thisContainer:MovieClip)

{

_loader = new SWFLoader("app:/assets/swfs/"+thisSWF+".swf", {container:thisContainer, noCache:true, context:DataModel.LoadContext, onInit:initLoadedSWF});

_loader.load();

}

 

private  function initLoadedSWF(event:LoaderEvent):void

assetMC = _loader.getSWFChild("mc_mc") as MovieClip;

EventController.getInstance().dispatchEvent(new ViewEvent(ViewEvent.ASSET_LOADED));

}

 

public function destroy():void

{

_loader.unload();

_loader.dispose(true);

_loader = null;

}

 

I have a ViewController class that loads each view. Before a new view is added, the current view's destroy method is called which calls the above destroy method. However, according to the Console in Flash Builder, the swfs aren't getting unloaded. Or at least not when needed. It seems to happen arbitrarily.

 

When I run the app for example I'll see this in the console:

 

[sWF] assets/swfs/Page1.swf 

[sWF] assets/swfs/Page2.swf

[sWF] assets/swfs/Page3.swf

[unload SWF] assets/swfs/Page1.swf

 

It should function above that Page1 gets loaded, and when selecting Page2, before it gets loaded, Page1 should unload through the unload() method which is being called. It's not behaving that way.

 

Shouldn't the SWFLoader unload() method be seen in the Console log if it is working as it should?

 

The thing is, depending on what page I start on, it will unload different swfs at different times. A guess to what's happening is when the app starts running out of memory, it unloads swfs as needed. Unfortunately, this causes the app to crash on the iPad.

 

Hope this makes sense.

 

Any ideas?

 

Thanks in advance for any help.

 

-Mark

Link to comment
Share on other sites

Hi, I'm not an Air/iOS developer or expert, but it appears the platform has some interesting ways of handling garbage collection.

 

This thread is quite telling: http://forums.adobe.com/message/5189873

 

It seems folks are having issues similar to you with just the native AS3 Loader. We haven't been able to identify any issues related to SWFLoader. 

 

If you find out any other useful info please let us know. Sometimes we can work around Flash Player bugs, but if there is something inherently odd with how GC works in AIR, there probably isn't much else we can do, but we're always interested in exploring. 

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

Hello again,

 

Update on this issue. Here is a list of things that caused my swfs to NOT unload.

 

* not flushing the content of the loader after unload i.e. 

   _loader.dispose(true);

* not nullifying private vars referencing Objects i.e. MovieClips in the asset

* setTimeouts that didn't fire - fixed with TweenMax delayed calls that got killed before leaving page i.e. TweenMax.killAll();

* having fonts embedded in library

   - think this would be considered bytecode which is not allowed in loaded swfs

* 1 stop() action on any frame. same explanation as previous

 

Hopefully, this helps someone else in a similar situation.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...