Skip to content

Instantly share code, notes, and snippets.

@robertpenner
Created March 9, 2010 18:32
Show Gist options
  • Save robertpenner/326911 to your computer and use it in GitHub Desktop.
Save robertpenner/326911 to your computer and use it in GitHub Desktop.
flash.net.URLLoader class decompiled from Flash 10 playerglobal.swc
//Created by Action Script Viewer - http://www.buraks.com/asv
package flash.net {
import flash.events.*;
import flash.utils.*;
public class URLLoader extends EventDispatcher {
private var stream:URLStream;
public var dataFormat:String;// = "text"
public var data;
public var bytesLoaded:uint;// = 0
public var bytesTotal:uint;// = 0
public function URLLoader(request:URLRequest=null){
super();
this.stream = new URLStream();
this.stream.addEventListener(Event.OPEN, this.redirectEvent);
this.stream.addEventListener(IOErrorEvent.IO_ERROR, this.onComplete);
this.stream.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.redirectEvent);
this.stream.addEventListener(HTTPStatusEvent.HTTP_STATUS, this.redirectEvent);
this.stream.addEventListener(ProgressEvent.PROGRESS, this.onProgress);
this.stream.addEventListener(Event.COMPLETE, this.onComplete);
if (request != null){
this.load(request);
};
}
public function load(request:URLRequest):void{
this.stream.load(request);
}
private function onProgress(event:ProgressEvent):void{
this.bytesLoaded = event.bytesLoaded;
this.bytesTotal = event.bytesTotal;
dispatchEvent(event);
}
public function close():void{
this.stream.close();
}
private function redirectEvent(event:Event):void{
dispatchEvent(event);
}
private function onComplete(event:Event):void{
var bytes:ByteArray = new ByteArray();
this.stream.readBytes(bytes);
switch (this.dataFormat){
case "binary":
this.data = bytes;
break;
case "variables":
if (bytes.length > 0){
this.data = new URLVariables(bytes.toString());
break;
};
case "text":
default:
this.data = bytes.toString();
break;
};
dispatchEvent(event);
}
}
}//package flash.net
@kontur
Copy link

kontur commented Oct 23, 2012

Thanks for the useful share. Couldn't believe flash.net.URLLoader does not provide access to the source url, but searching for a remedy led me here. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment