flash on 2011-4-30
♥0 |
Line 44 |
Modified 2011-04-30 20:11:09 |
MIT License
archived:2017-03-20 11:23:55
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/dRq8
*/
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.getTimer;
public class FlashTest extends Sprite {
var aPoints:Vector.<Point>;
public function FlashTest() {
// write as3 code here..
var i:int, t:int;
var iLoops:int = 100000;
var pt:Point = new Point(1, 1);
var txt:TextField = new TextField();
txt.autoSize = TextFieldAutoSize.LEFT;
txt.multiline = true;
addChild(txt);
aPoints = new Vector.<Point>;
for (i = 0; i < iLoops; i++) {
aPoints.push(new Point(i, i));
}
t = getTimer();
for (i = 0; i < iLoops; i++) {
aPoints[i].x += pt.x;
}
t = getTimer() - t;
txt.appendText("Getter/Setter: " + t + "ms\n");
t = getTimer();
for (i = 0; i < iLoops; i++) {
aPoints[i].y += pt.y;
}
t = getTimer() - t;
txt.appendText("Raw: " + t + "ms\n");
}
}
}
class Point {
private var _x:Number;
public var y:Number;
function Point(x0:Number, y0:Number) {
_x = x0;
y = y0;
}
function get x() :Number { return _x;}
function set x(inX:Number):void {_x = inX;}
}