function game(){ var originaltext = "Hello Sphere Worlds!"; var source = CreateByteArrayFromString( originaltext ); var compressed = DeflateByteArray( source , 9); // Sphere Syntax //var compressed = source.deflate(9); // MiniSphere Syntax if( compressed !== null ){ var inflated = InflateByteArray(compressed, 1024*16); // Sphere Syntax //var inflated = compressed.inflate(); // MiniSphere Syntax if(inflated !== null){ var copy = CreateStringFromByteArray(inflated); if(copy === originaltext) Abort( "SUCCES:" + CreateStringFromByteArray(inflated) ); else Abort("ByteArray to string failed"); }else{ Abort( "Decompression failed." ); } }else{ Abort("Compression failed.") }}// MiniSphere to Sphere syntaxfunction DeflateByteArray(BA_obj,ratio){ return BA_obj.deflate(ratio);}function InflateByteArray(BA_obj,size){ return BA_obj.inflate(size); // need size or we can make a inflate bomb?}
You also pulled in zlib once you supported png.
Works perfectly:Code: [Select]function game(){ var originaltext = "Hello Sphere Worlds!"; var source = CreateByteArrayFromString( originaltext ); var compressed = DeflateByteArray( source , 9); // Sphere Syntax //var compressed = source.deflate(9); // MiniSphere Syntax if( compressed !== null ){ var inflated = InflateByteArray(compressed, 1024*16); // Sphere Syntax //var inflated = compressed.inflate(); // MiniSphere Syntax if(inflated !== null){ var copy = CreateStringFromByteArray(inflated); if(copy === originaltext) Abort( "SUCCES:" + CreateStringFromByteArray(inflated) ); else Abort("ByteArray to string failed"); }else{ Abort( "Decompression failed." ); } }else{ Abort("Compression failed.") }}// MiniSphere to Sphere syntaxfunction DeflateByteArray(BA_obj,ratio){ return BA_obj.deflate(ratio);}function InflateByteArray(BA_obj,size){ return BA_obj.inflate(size); // need size or we can make a inflate bomb?}
Didn't original Sphere never throw exceptions because implementing exceptions was a difficult mess, or am I wrong on that? Even if it did though, it'd be pretty inconsistent with everything else. I've never seen try..catch in Sphere...
On that note, the minisphere error screen is so much nicer looking than the Sphere 1.5 one. Just have to toot my own horn a little...