Hi, I have a function that loads my map from an XML File… Il seems that I can’t return any value from the function when I have a XML object open, if i trace() the array directly from the function, it work nicely…
Here is my LoadMap function
function LoadMap(XMLFile:String) {
xml = new XML();
xml.ignoreWhite = true;
xml.load(XMLFile);
xml.onLoad = function(flag) {
if(flag) {
var MapXML = xml.firstChild;
var i:Number = 0;
var mapArray = new Array();
while(MapXML.childNodes* != undefined) { //We list every row for map
var j:Number = 0;
var RowXML = MapXML.childNodes*;
mapArray* = new Array();
while(RowXML.childNodes[j] != undefined) {
var CellXML = RowXML.childNodes[j];
mapArray*[j] = CellXML.attributes.type;
j++;
}
i++;
}
//trace(mapArray); //return the two dimensionnal map array.
return (mapArray);
} else { //Error.
trace("Impossible de charger " + XMLFile);
return(false);
}
}
}
… and my XML File
<?xml version="1.0" encoding="iso-8859-2"?>
<map name="LightHaven">
<row>
<cell type="1" />
<cell type="1" />
<cell type="1" />
<cell type="1" />
<cell type="1" />
<cell type="1" />
<cell type="1" />
<cell type="1" />
</row>
<row>
<cell type="2" />
<cell type="2" />
<cell type="2" />
<cell type="2" />
<cell type="2" />
<cell type="2" />
<cell type="2" />
<cell type="2" />
</row>
</map>
Could you help me to find how to solve this problem ? Because it appear at every function that I put XML Object in…
Thanks!