This is the way I've set up an application (not in the SFV framework) to read in a configuration file. The application is a framework where I'm showing the data for several different projects and the XML contains all the parameters for each project, including map service and query URLs. I pass in a parameter in the main URL for the specific project:http://ccma.nos.noaa.gov/explorer/biomapper/biomapper.html?id=JobosBayhttp://ccma.nos.noaa.gov/explorer/biomapper/biomapper.html?id=StJohnThis is the code for the Flex application to read in the XML file
private var xmlParameters:XML;
private var xmlProjectParameters:XMLList;
private function init():void
{
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE,init_onComplete);
xmlLoader.addEventListener(IOErrorEvent.IO_ERROR,fail);
xmlLoader.load(new URLRequest("parameters.xml"));
}
private function fail(event:Event)
{
Alert.show("Fail");
}
private function init_onComplete(event:Event):void
{
var params:Object;
try
{
var loader:URLLoader = URLLoader(event.target);
xmlParameters = new XML(loader.data);
params = getURLParameters();
if (params["id"])
{
input = params.id
}
else
{
Alert.show("Parameter search failed");
return;
}
xmlProjectParameters = xmlParameters.project.(@urlinput==input);
var bm:IBrowserManager = BrowserManager.getInstance();
bm.init();
bm.setTitle(xmlProjectParameters.@id + " BIOMapper");
serverName = xmlProjectParameters.service;
projectTitle = xmlProjectParameters.projectname.@name;
if (!(xmlProjectParameters.datalayers.dive==undefined))
{
diveQueryTask.url = serverName + xmlProjectParameters.datalayers.dive.@url + "/MapServer/" + xmlProjectParameters.datalayers.dive.@layer;
etc...
}
private function getURLParameters():Object
{
var result:URLVariables = new URLVariables();
try
{
if (ExternalInterface.available)
{
var search:String = ExternalInterface.call("location.search.substring", 1);
if (search && search.length > 0)
{
result.decode(search);
}
}
}
catch (error:Error)
{
Alert.show(error.toString());
}
return result;
}
And this is the code for the XML file
<?xml version="1.0" encoding="utf-8"?>
<projects>
<project id="Jobos Bay" urlinput="JobosBay">
<projectname name ="Jobos Bay, PR" pdftitle="Jobos Bay, PR: Shallow-water Benthic Habitats" url="http://ccma.nos.noaa.gov/ecosystems/coralreef/ceap/"/>
<service>http://egisws02.nos.noaa.gov/ArcGIS/rest/services/biomapper/Jobos_</service>
<datalayers>
<dive layer="0" url="Dynamic" site_id="Site_ID" videoname="Site_ID" assessment="Assessment" photocount="PhotoCount" symbol="Symbol" legendurl="http://ccma.nos.noaa.gov/explorer/biomapper/jobosbay/images/Dives.png" legendheight="53">
</dive>
</datalayers>
etc
</project>
<project id="St. John" urlinput="StJohn">
<projectname name="St. John, U.S. Virgin Islands" pdftitle="U.S. Virgin Islands (St. John): Shallow- and Moderate-Depth Benthic Habitats" url="http://ccma.nos.noaa.gov/ecosystems/coralreef/benthic/"/>
<service>http://egisws02.nos.noaa.gov/ArcGIS/rest/services/biomapper/StJ_</service>
<datalayers>
<dive layer="13" url="all" site_id="SITE_ID" videoname="VIDEONAME" assessment="ASSESSMENT" photocount="PHOTOCOUNT" symbol="SYMBOL" legendurl="http://ccma.nos.noaa.gov/explorer/biomapper/stjohn/images/Dives.png" legendheight="103">
</dive>
etc.
</project>
</projects>