Copy link to clipboard
Copied
Hi there
I have a string, I am compressing it with bytearray and save it to a file...
in other application i am loading it and when i try to uncompress it, it's give me an error...
How can I convert a compressed string in to bytearray type to be able to convert it ?
the code for compression:
var b:ByteArray = new ByteArray();
b.writeMultiByte(t,"iso-8859-1")
b.compress();
Thanks
Copy link to clipboard
Copied
And the code for loading and trying to uncompress:
function handleSendComplete1(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
var b:ByteArray = new ByteArray();
b.writeUTFBytes(loader.data)
b.uncompress();
trace(b)
}
and the error:
Error #2058: There was an error decompressing the data.
at flash.utils::ByteArray/uncompress()
at MethodInfo-1()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Copy link to clipboard
Copied
nobody cand help me ?
Copy link to clipboard
Copied
I have a string, I am compressing it with bytearray and save it to a file...
How are you saving the ByteArray to the file?
function handleSendComplete1(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
var b:ByteArray = new ByteArray();
b.writeUTFBytes(loader.data)
b.uncompress();
trace(b)
}
What URLLoaderDataFormat did you assign to the URLLoader instance? URLLoaderDataFormat.TEXT? URLLoaderDataFormat.BINARY?
If the file was saved in binary format, and then loaded as such, loader.data would already be a ByteArray, so why are you using writeUTFBytes? If the orginal ByteArray was encoded and the file was saved in text format, you would need to decode loader.data (string) and then load assign the result to a ByteArray.
Need more info.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now