I've been reading through the manuals and the API's. I can't find a section which explains how the main game's .fla (and the OpenSpace compiled clip in it), recognises the location for all the maps that are created and exported by the OpenSpace Map Editor. I have an existing project that I have just taken over. The game's swf source location has a folder named 'maps', It contains the following code in 'MapsLoadingManager':
Code: Select all
private function loadMapAssets(skinSwfFilenames:Array, bgSwfFilenames:Array):void
{
/* IMPORTANT NOTE: for sake of simplicity, in this example both skins and backgrounds swf files are loaded in the same application domain.
A number of improvements should be made:
1) application domains should be kept separate between skins and backgrounds swf files, in order to avoid possible conflicts in case the class definitions they contain have the same names;
2) in case the loaded map shares the same swf files of the previous map, reloading is unnecessary and should be avoided not to waste memory;
3) if swf files for the previous map are not needed anymore, they should be unloaded. */
mapAssetsLibrariesAppDomain = new ApplicationDomain()
var fileNames:Array = skinSwfFilenames.concat(bgSwfFilenames)
loadCounter = fileNames.length
tempLoaders = [] // We have to keep a reference to the loaders to avoid a bug in the Flash Player: http://bugs.adobe.com/jira/browse/FB-13014
if (loadCounter > 0)
{
main.logTrace("External swf files to be loaded: " + fileNames)
for (var i:int = 0; i < loadCounter; i++)
{
var loader: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)
}
}
else
onMapSwfFileLoaded(null)
}
/**
* swf file loaded: when all the required swf files are loaded, map rendering can be launched.
*/
private function onMapSwfFileLoaded(evt:Event):void
{
loadCounter--
if (loadCounter <= 0)
{
main.logTrace("External libraries loaded, now the loaded map can be rendered")
// The same value is passed to both skinAppDomain and bgAppDomain parameters: check the comment to loadMapAssets method above.
openSpace.skinAppDomain = mapAssetsLibrariesAppDomain
openSpace.bgAppDomain = mapAssetsLibrariesAppDomain
// Render map
openSpace.renderMap()
}
}
However I'm unsure whether this is creating a reference to the actual maps themselves which hold the tile coordinates for each map, or whether this simply creates a reference to all the swf assets which are used in the game by the map editor.
Is there somewhere which gives a breakdown of how the game's .fla (and OpenSpace) recongnise and collect map data? If not, could someone please let me know how OpenSpace collects the original map data when the game loads?
Many Thanks
Nigel