Flash AS3 read proxy server response with URLLoader

314 Views Asked by At

I am running an embedded flash 'swf' inside a LAN network with a proxy server. Proxy server interrupts some urls and returns my usage information. I am trying to access this information by sending those urls. I can see this traffic in firebug ,But the URLLoader does not seem to read it. Neither Complete event or progress event get fired. I tried URLStream with a timer also,but availableBytes were always zero.Is it possible to read this information?

  private var getLoader:URLLoader = new URLLoader();
  private var sendRequest:URLRequest = new URLRequest();
  public function XDomain() {
   sendRequest= new URLRequest("requesturl");
   getLoader.addEventListener(Event.COMPLETE, eventHandler);
   getLoader.addEventListener(ProgressEvent.PROGRESS,eventHandler2);
   getLoader.load(sendRequest);
  }
  private function eventHandler(event:Event):void {
    trace("running");
  }
  private function eventHandler2(event:ProgressEvent):void {
   trace("runninhg progresss");
  }

Thanks in advance // Edit: I had this security error

[SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048"]
1

There are 1 best solutions below

6
On

"But the URLLoader does not seem to read it..."

Use URLStream (without a timer, cos what does that even achieve?) to reach the link and inside your related progressEvent use a readUTFBytes to get any text response data given by that link's server. Use progressEvent to also check size of any received bytes (the event fires multiple times, getting 64kb packets, until full data is downloaded).

about Error #2048:
URLloader is a decoder for visual data (jpg, png, swf, text) but for non-text data it expects a crossdomain.xml to exist at the other server you are accessing the swf from (both sides must also have a matching same http or https. Again best way to by-pass this is to just load the bytes into a byte array (via URLStream but the progressEvents now should write to your byte array) then later use URLLoader.loadBytes( yourSWFBytes );