unload swf files of the previous map

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

unload swf files of the previous map

Postby Madhav » 01 Apr 2013, 12:45

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....
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: unload swf files of the previous map

Postby Bax » 02 Apr 2013, 09:03

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.
Paolo Bax
The SmartFoxServer Team
Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Re: unload swf files of the previous map

Postby Madhav » 02 Apr 2013, 09:21

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....
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: unload swf files of the previous map

Postby Bax » 02 Apr 2013, 09:34

Simply use the _swfLoader.unloadAndStop() method, without removing the swf from the stage (which actually is never added to it).
Paolo Bax
The SmartFoxServer Team
Madhav
Posts: 78
Joined: 27 Nov 2012, 04:41

Re: unload swf files of the previous map

Postby Madhav » 02 Apr 2013, 10:21

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...
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: unload swf files of the previous map

Postby Bax » 02 Apr 2013, 13:26

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.
Paolo Bax
The SmartFoxServer Team

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 15 guests