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