Created
March 9, 2010 18:32
-
-
Save robertpenner/326911 to your computer and use it in GitHub Desktop.
flash.net.URLLoader class decompiled from Flash 10 playerglobal.swc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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. :)