Accessing Data Being Downloaded : URLStream « Network « Flash / Flex / ActionScript






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

        








Related examples in the same category

1.Add Process Listener to URLStream