Flash / Flex / ActionScript/Network/URLStream
Accessing Data Being Downloaded
package {
import flash.display.*;
import flash.events.*
import flash.net.*;
public class Main extends Sprite {
public function Main( ) {
var streamer:URLStream = new URLStream( );
streamer.addEventListener( ProgressEvent.PROGRESS, handleProgress );
streamer.load( new URLRequest( "example.txt" ) );
}
private function handleProgress( event:ProgressEvent ):void {
var streamer:URLStream = URLStream( event.target );
while ( streamer.bytesAvailable > 0 ) {
trace( "Read byte: " + streamer.readByte( ) );
}
}
}
}
Add Process Listener to URLStream
package
{
import flash.net.URLStream;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;
public class Main
{
private var streamer:URLStream= new URLStream(new URLRequest("http://example.ru/binary_data.bin"));
public function Main()
{
streamer.addEventListener(ProgressEvent.PROGRESS, progressListener);
}
private function progressListener(event:Event):void
{
if(streamer.bytesAvailable != 0)
{
trace(streamer.readByte());
}
}
}
}