Here's the way I have it one of my applications. Once the XML file is finishing being read, if the XML file contains the extents node, I create an array that holds the extents and make that the dataprovider for my combobox cboExtent.
private var xmlParameters:XML;
public var xmlProjectParameters:XMLList;
private function init():void
{
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("parameters.xml"));
xmlLoader.addEventListener(Event.COMPLETE,init_onComplete);
}
private function init_onComplete(event:Event):void
{
var extentArray:ArrayCollection = new ArrayCollection;
try
{
var loader:URLLoader = URLLoader(event.target)
xmlParameters = new XML(loader.data)
xmlProjectParameters = xmlParameters.project.(@id=="Testing")
if (!(xmlParameters.extents == undefined))
{
cboExtent.visible = true;
for (var i:int = 0; i < xmlProjectParameters.extents.extent.length(); i++)
{
extentArray.addItem({label:xmlProjectParameters.extents.extent.@name.toString(), xmin: xmlProjectParameters.extents.extent.@xmin.toString(), ymin: xmlProjectParameters.extents.extent.@ymin.toString(), xmax: xmlProjectParameters.extents.extent.@xmax.toString(), ymax: xmlProjectParameters.extents.extent.@ymax.toString()});
}
cboExtent.dataProvider = extentArray;
}
This is what the Close event looks like for the combobox.
public function cboExtent_Close():void
{
var extent:Extent = new Extent(Number(cboExtent.selectedItem.xmin), Number(cboExtent.selectedItem.ymin), Number(cboExtent.selectedItem.xmax), Number(cboExtent.selectedItem.ymax))
mainMap.extent = extent;
}
and this is what the XML file looks like
<projects>
<project id="Testing">
<extents>
<extent name="Full Extent" xmin="-7389794" ymin="2023797" xmax="-7360030" ymax="2040131"/>
<extent name="Zoomin" xmin="-7370000" ymin="2030000" xmax="-7365000" ymax="2035000"/>
</extents>
</project>
</projects>