March 31st, 2008 - Microcomputer Systems class
Frame rate is 6.0 fps for the slower Event.ENTER_FRAME listener
var n:uint = 0;
var lineCanvas:Shape = new Shape();
addChild(lineCanvas);
function drawLine(e:Event):void {
with (lineCanvas) {
graphics.moveTo(275, 200);
var c:int = Math.floor(Math.random()* 0xFFFFFF);
if (n % 3 == 0) {
graphics.lineStyle(5, 0xFF0000);
} else if (n % 3 == 1) {
graphics.lineStyle(5, 0xFFFFFF);
} else {
graphics.lineStyle(5, 0x0000FF);
}
var x:Number = Math.random()* 550;
var y:Number = Math.random()*400;
graphics.lineTo(x, y);
n++;
}
}
addEventListener(Event.ENTER_FRAME, drawLine);
for (var i:uint = 1; i <= 10000; i++) {
drawLine2();
}
function drawLine2():void {
with (lineCanvas) {
// graphics.clear();
graphics.moveTo(275, 200);
var c:int = Math.floor(Math.random()* 0xFFFFFF);
graphics.lineStyle(1, c);
var x:Number = Math.random()* 550;
var y:Number = Math.random()*400;
var xDist = x - 275;
var yDist = y - 200;
if ( Math.sqrt( xDist*xDist + yDist*yDist ) <= 200 ) {
graphics.lineTo(x, y);
}
}
}