Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

bytearray uncompress

Explorer ,
Oct 12, 2009 Oct 12, 2009

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

TOPICS
ActionScript
3.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 12, 2009 Oct 12, 2009

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()

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 14, 2009 Oct 14, 2009

nobody cand help me ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 16, 2009 Oct 16, 2009
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines