I have a custom data file from a project that was authored in actionscript some years ago by another developer. I am porting parts of the project over to Unity 3D. I don't have any documentation for the original project (I hope to speak to the original developers at some point but I cannot wait for that).
The file is a special bitmap that represents the positions of objects on a grid. The custom file is created using an editor created in Adobe air. I believe (not knowing any better) that the source code I have for the file decoder is the same source from the editor. I don't have the editor source code.
Where I am getting into trouble is the binary file. From what I can tell at the moment, the file is a compressed byte array on the Adobe air side of things. I don't believe I can just load the compressed file with Unity3D as a resource object. I would like to decompress the file and use it as an asset in Unity.
I am trying to figure how to decompress the binary file. I have tried viewing the file contents in a hex editor to establish what the compression format is with no joy; I have not done anything specifically like this before 😊. I have tried to use gzip and a few other apps to decompress the file.
Form what I have read in the action script documentation that the default compression should be zlib.
Here is some edited code from the original project for decoding the bitmap:
import flash.utils.ByteArray;
public function decode(byteArray:ByteArray):Boolean
{
var i:uint;
var j:uint;
if(colourMap!=null)
{
colourMap.dispose();
depthMap.dispose();
}
byteArray.uncompress();
byteArray.position=0;
var fileVersion:String=byteArray.readUTFBytes(FILE_VERSION.length);
if(fileVersion==FILE_VERSION)
{
numWidth=byteArray.readUnsignedInt();
numHeight=byteArray.readUnsignedInt();
if(numWidth==0)
{
numWidth=30;
trace("WARNING FOR SOME REASON WIDTH WAS 0 FROM FILE");
}
if(numHeight==0)
{
numHeight=30;
trace("WARNING FOR SOME REASON HEIGHT WAS 0 FROM FILE");
}
Here is a hex dump of the initial part of the binary data file:
78 da ec bd 55 cf 6c 5d 76 a5 79 7c 53 2a ff 8c