Created
June 29, 2010 18:54
-
-
Save wolever/457618 to your computer and use it in GitHub Desktop.
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
<?xml version="1.0" encoding="utf-8"?> | |
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:text="flash.text.*"> | |
<mx:Script><![CDATA[ | |
import flash.utils.setTimeout; | |
protected function range(n:int):Array { | |
var result:Array = []; | |
while (n-- > 0) | |
result.push(n); | |
return result; | |
} | |
protected function startTest0():void { | |
var stuff:Array = []; | |
var bigStuff:Array = range(10000); | |
var t:Timer = new Timer(1000, int.MAX_VALUE); | |
t.addEventListener(TimerEvent.TIMER, function(e:*):void { | |
btn0.label = String(int(btn0.label) + 1); | |
stuff.push(bigStuff.concat([])); | |
}); | |
t.start(); | |
} | |
protected function startTest1():void { | |
var stuff:Array = []; | |
var bigStuff:Array = range(1000000); | |
var t:Timer = new Timer(70*1000, int.MAX_VALUE); | |
t.addEventListener(TimerEvent.TIMER, function(e:*):void { | |
btn1.label = String(int(btn1.label) + 1); | |
stuff.push(bigStuff.concat([])); | |
}); | |
t.start(); | |
} | |
protected function startTest2():void { | |
var loader:URLLoader = new URLLoader(); | |
loader.addEventListener(Event.COMPLETE, function(e:*):void { | |
btn2.label = String(int(btn2.label) + 1); | |
setTimeout(function():void { | |
loader.load(new URLRequest("http://example.com")); | |
}, 1000); | |
}); | |
function error(e:Event):void { | |
btn2.label = "URLLoader error!"; | |
} | |
loader.addEventListener(IOErrorEvent.IO_ERROR, error); | |
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, error); | |
loader.load(new URLRequest("http://example.com")); | |
} | |
]]></mx:Script> | |
<mx:creationComplete><![CDATA[ | |
startTest0(); | |
startTest1(); | |
startTest2(); | |
]]></mx:creationComplete> | |
<mx:Button id="btn0" label="0"> | |
</mx:Button> | |
<mx:Button id="btn1" label="0"> | |
</mx:Button> | |
<mx:Button id="btn2" label="0"> | |
</mx:Button> | |
</mx:Application> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment