Problem reading ByteArray()

Hi,

I’m trying to read the information stored in a ByteArray() but im getting garbage out of it. I created the input binary file in C# with an editor I designed and it was tested for correction so we can discard the file is mal-formatted (if that is a word).

Here is the reading file code:


var myLoader:URLLoader;
public function LoadGame()
{
 	this.myLoader = new URLLoader();
	             this.myLoader.dataFormat = URLLoaderDataFormat.BINARY;
	             this.myLoader.load(new URLRequest(this.ActiveMapName));
	             this.myLoader.addEventListener(Event.COMPLETE, fileLoaded)
}
		
private function fileLoaded(event:Event) 
{
	           var mapData:ByteArray = new ByteArray();
	           mapData = this.myLoader.data;
   
           this.tileMap = new TileMap(MovieClip(this), 10, 7);
	           this.tileMap.LoadFromFile2(mapData);
			
	           this.Start();
}

This part seems to be working fine. When I do a mapData.length trace I get the correct number of bytes read. The problem seems to be when reading using mapData.readInt() which returns a crazy number like 16777216 instead of the expected 1 for example.

Here is the code:


public function LoadFromFile2(inputArray:ByteArray)
{
 	// Read map header
	            this.TileSetID = inputArray.readInt();
            this.TileColumnCount = inputArray.readInt();
	            this.TileRowCount = inputArray.readInt();
            this.TileSize = inputArray.readInt();

            ...
}
 
As I said before I read this file in C# in the same manner and it returns the correct values. Help!