flash on 2012-3-20
♥0 |
Line 38 |
Modified 2012-04-24 09:36:33 |
MIT License
archived:2017-03-29 13:16:39
ActionScript3 source code
/**
* Copyright wh0 ( http://wonderfl.net/user/wh0 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/hUl5
*/
package {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.utils.*;
import com.actionscriptbible.Example;
public class FlashTest extends Example {
private static const RESOURCE:String = 'http://0:9988/garply.png';
private var flow:Number = 0;
public function FlashTest() {
loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, function (e:UncaughtErrorEvent):void { trace('UNCAUGHT_ERROR\t' + e.error); });
startRequest();
}
private function startRequest():void {
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(Event.COMPLETE, function (e:Event):void {
addResult('COMPLETE ' + e.target.bytes.length + '/' + e.target.bytesLoaded, e);
trace(xd(e.target.bytes, 66));
});
l.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function (e:IOErrorEvent):void {
addResult('IO_ERROR', e);
trace(e.target.bytes.length);
});
l.load(new URLRequest(RESOURCE));
}
private function xd(ba:ByteArray, n:int):String {
var x:String = '';
for (var i:int = 0; i < 62; i++) {
var b:int = ba[i];
x += b >= 32 && b <= 126 ? String.fromCharCode(b) : '.';
}
return x;
}
private function addResult(result:String, event:Event):void {
trace(result + '\t' + event);
}
}
}