I've been complaining to Adobe about the lack of a output progress event for a while now. However today I found a suitable work around.

actionscript Code:
private var _interval:unit;

private function upload():void {
       interval = setInterval(sendData, 0);
}

private function sendData():void {

        _bufferRate = System.freeMemory / 2;

    if (_fileStream.bytesAvailable < _bufferRate)
        _bufferRate = _fileStream.bytesAvailable;
           
    if (_fileStream.bytesAvailable <= 0){
        clearInterval(_interval);
        _passiveStream.close();
        return;
    }
           
    var ba:ByteArray = new ByteArray();
    _fileStream.readBytes(ba, 0, _bufferRate);
    _socket.writeBytes(ba, 0, ba.bytesAvailable);
    _socket.flush();
}

I've used an interval to upload the data in batches. However what i was doing before was uploading batches in a megabyte per interval.

that caused the flex allocated memory to overflow (i need to do more testing to work out the exact cause of lost packets), and the data to be lost.

For example my university connection speed is about 8 megabytes per sec, and i tested uploading a 366mb file, and only 100mb reached the server.

If anyone can help me work out the exact cause of this i would be grateful. However, my solution seems to be working (i need to test it on a low performance machine, i.e. my laptop, to be sure though).

The System.freeMemory is flexible, but i beleive that it cant be exceeded. Normally when the free space is used, more is allocated, but it mustn't over flow. So a "System.freeMemory / 2" as the buffer for the length para in a read method e.g.

_fileStream.readBytes(ba, 0, _System.freeMemory / 2);

will prevent to much data being input.



Any improvements to this workaround will be appriciated. thank you

Flos