Page 1 of 1

unload swf files of the previous map

Posted: 01 Apr 2013, 12:45
by Madhav
Hai....
I needed some info about unloading the swf files of the previous map that are not needed anymore...

I am using the basic methods of loading and adding the swfs of map... like

private function loadMapAssets(skinSwfFilenames:Array, bgSwfFilenames:Array):void
{
mapAssetsLibrariesAppDomain = new ApplicationDomain()
var fileNames:Array = skinSwfFilenames.concat(bgSwfFilenames)
loadCounter = fileNames.length
tempLoaders = []
if (loadCounter > 0)
{

for (var i:int = 0; i < loadCounter; i++)
{
loader = new Loader()
tempLoaders.push(loader)
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMapSwfFileLoaded)
var request:URLRequest = new URLRequest("libraries/" + fileNames[i])
var context:LoaderContext = new LoaderContext(false, mapAssetsLibrariesAppDomain)

loader.load(request, context);
}
}
}

private function onMapSwfFileLoaded(evt:Event):void
{
loadCounter--;
if (loadCounter <= 0)
{
openSpace.skinAppDomain = mapAssetsLibrariesAppDomain;
openSpace.bgAppDomain = mapAssetsLibrariesAppDomain;

// Render map
var params:MapCenteringParams = new MapCenteringParams();
params.px = 383;
params.py = 239;
openSpace.renderMap(params);
}
}

I am not getting how exactly to unload the swfs of previous map while loading a new map since the adding is done like this
openSpace.skinAppDomain = mapAssetsLibrariesAppDomain;
openSpace.bgAppDomain = mapAssetsLibrariesAppDomain;
Please Help....

Re: unload swf files of the previous map

Posted: 02 Apr 2013, 09:03
by Bax
The map unloading is done automatically when you load a new map or if you call the IOpenSpaceAPI.unloadMap method.
Of course this doesn't unload the SWF files containing the assets.
In order to do it you have to use the default methods available in Flash. Make a search on Google. Also you don't have to worry about the appDomain assignment, but in any case you can still set it to null.

Re: unload swf files of the previous map

Posted: 02 Apr 2013, 09:21
by Madhav
Thanks Bax,
I do want to unload the SWF files containing the assets since I have got some sounds in the timeline of BG movieclip in background swf. If i dont unload swf the sounds wont stop. So you said to use the default methods available in Flash I think like,
_swfLoader.unloadAndStop();
stage.removeChild(_swfLoader);
_swfLoader= null;

But since the swf's are not added to stage or openSpace instead they are just assigned as,
openSpace.skinAppDomain = mapAssetsLibrariesAppDomain;
openSpace.bgAppDomain = mapAssetsLibrariesAppDomain;

I didnt get how exactly to unload them???
This may be a simple/silly question but please do reply....

Re: unload swf files of the previous map

Posted: 02 Apr 2013, 09:34
by Bax
Simply use the _swfLoader.unloadAndStop() method, without removing the swf from the stage (which actually is never added to it).

Re: unload swf files of the previous map

Posted: 02 Apr 2013, 10:21
by Madhav
But I think the swf is not unloaded since the the sounds in the background swf of old map are not removed they keep on playing. And the sounds in old maps swf and new map BG swf are playing together,, Not getting how to proceed :( Please guide...

Re: unload swf files of the previous map

Posted: 02 Apr 2013, 13:26
by Bax
Not sure how to help further, as this seems to be related to Flash entirely.
Check these post for example:
http://stackoverflow.com/questions/3930 ... s-unloaded
http://stackoverflow.com/questions/5013 ... in-audible

I think you will need to stop the sound manually.