Hello,
I'm trying to compress XML data being exchanged via Socket with a Perl
backend and after taking several hurdles, I'm stuck at this error message:
1061: Call to a possibly undefined method inflate through
a reference with static type flash.utils:ByteArray.
My code is:
private var _nbytes:int = 0;
private var _bytes:ByteArray = new ByteArray();
private var _socket:Socket = new Socket();
.....
// the length of XML-string is prepended as a short (2 bytes)
private function handleTcpData(event:ProgressEvent):void {
trace('handleTcpData: ' + event);
while (_socket.bytesAvailable > 0) {
if (_nbytes <= 0) {
if (_socket.bytesAvailable < 2) {
trace('Can not read short yet -
bytesAvailable='+
_socket.bytesAvailable);
return;
}
try {
_nbytes = _socket.readShort();
trace('Read _nbytes '+_nbytes);
} catch (e:Error) {
handleTcpError();
}
} else {
if (_socket.bytesAvailable < _nbytes) {
trace('Can not read bytes yet -
bytesAvailable='+
_socket.bytesAvailable+' <
_nbytes='+_nbytes);
return;
}
try {
_socket.readBytes(_bytes, 0,
_nbytes);
trace('Read _bytes
'+_bytes.length);
} catch (e:Error) {
handleTcpError();
}
}
try {
_bytes.inflate(); // this fails for
some reason?
} catch (error:IOError) {
trace('inflating failed');
}
trace(_bytes.length);
trace(_bytes);
//updateGUI(_bytes);
}
}
Can anyone please spot an error in the code above?
I've started preparing a simple test case, but the following just works:
import flash.utils.*;
var _bytes:ByteArray = new ByteArray();
_bytes.writeUTFBytes('Hello world');
trace('before: ' + _bytes);
try {
_bytes.deflate();
_bytes.inflate();
} catch (e:Error) {
trace(e);
}
trace('after: ' + _bytes);
Thank you for any hints
Alex
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders