# Help with converting an XML into a 2D level (Actionscript 3.0)

I'm making a little platformer and wanted to use Ogmo to create my level. I've gotten everything to work except the level that my code generates is not the same as what I see in Ogmo. I've checked the array and it fits with the level in Ogmo, but when I loop through it with my code I get the wrong thing. I've included my code for creating the level as well as an image of what I get and what I'm supposed to get.

EDIT: I tried to add it, but I couldn't get it to display properly

Also, if any of you know of better level editors please let me know.

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
{
levelXML = new XML(e.target.data);
xmlFilter = levelXML.*
for each (var levelTest:XML in levelXML.*)
{
crack = levelTest;
}
levelArray = crack.split('');
trace(levelArray);
count = 0;
for(i = 0; i <= 23; i++)
{
for(j = 0; j <= 35; j++)
{
if(levelArray[i*36+j] == 1)
{
block = new Platform;
block.x = j*20;
block.y = i*20;
count++;
trace(i);
trace(block.x);
trace(j);
trace(block.y);
}
}
}
trace(count);


• Can you share the "Level1.oel" file so we can figure out how data are organised and how they should be parsed ? – Valkea Jun 23 '12 at 18:58

this is just a guess but can you make sure your "levelArray" does't contain "\n" at the end of each line. maybe changing your condition to if(levelArray[i*37+j] == 1) solve the problem. note that it might also have an extra "\n\r" at the end of each line. In that case you need to multiply i by 38 in that condition.