Re: [Flashcoders] How to remove bytes from the beginning of a ByteArray?

2010-02-24 Thread Alexander Farber
In my desperation I've asked the same question in a german and a russian forum last night. And where do I find the useful replies in the morning? This mailing list is priceles :-) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chat

Re: [Flashcoders] How to remove bytes from the beginning of a ByteArray?

2010-02-23 Thread Steven Sacks
private var buffer:ByteArray; private function onData(event:ProgressEvent):void { socket.readBytes(buffer, buffer.length); var bytes:ByteArray = new ByteArray(); buffer.readBytes(bytes, 0, messageLength); buffer.position = bytes.length; trim(); // deserialize the message i

Re: [Flashcoders] How to remove bytes from the beginning of a ByteArray?

2010-02-23 Thread Steven Sacks
FWIW, flush() does nothing in AS3. Bytes written to the Socket are sent immediately. Anyone who tells you otherwise has never tested it and you can safely ignore them! :) Adobe has acknowledged this as a documentation bug (whatever that means). For more info: http://www.stevensacks.net/20

Re: [Flashcoders] How to remove bytes from the beginning of a ByteArray?

2010-02-23 Thread Juan Pablo Califano
Hi, You've got the source / destination backwards. readBytes reads *from* the object on which the method is called. And it writes *to* the ByteArray you pass in the first parameter. So this: var newBA:ByteArray = new ByteArray(); newBA.readBytes(_ba); _ba = newBA; Is copying data *from* newBA

[Flashcoders] How to remove bytes from the beginning of a ByteArray?

2010-02-23 Thread Alexander Farber
Hello, sorry, but I'll try to start another thread to explain my problem. I read data from a socket into a ByteArray _ba and keep inspecting it. When there is enough data, I'd like to extract and process it and remove the processed bytes from the _ba. Here is how I try to do the removal, but it