forked from: flash on 2011-4-30
forked from flash on 2011-4-30 (diff: 30)
ActionScript3 source code
/**
* Copyright John_Blackburne ( http://wonderfl.net/user/John_Blackburne )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/bpL8
*/
// forked from John_Blackburne's flash on 2011-4-30
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.getTimer;
public class FlashTest extends Sprite {
static const aCols:Vector.<uint> = Vector.<uint>([
0xff0000,0x00ff00, 0x0000ff
]);
public function FlashTest() {
// write as3 code here..
var color:uint;
var i:int, t:int;
var iLoops:int = 100000;
var txt:TextField = new TextField();
txt.autoSize = TextFieldAutoSize.LEFT;
txt.multiline = true;
addChild(txt);
t = getTimer();
for (i = 0; i < iLoops; i++) {
color = [0xff0000,0x00ff00, 0x0000ff][Math.random()*3>>0]
}
t = getTimer() - t;
txt.appendText("First: " + t + "ms\n");
t = getTimer();
for (i = 0; i < iLoops; i++) {
color = aCols[Math.random() * 3 >> 0];
}
t = getTimer() - t;
txt.appendText("Second: " + t + "ms\n");
}
}
}
