check
click
/**
* Copyright Scmiz ( http://wonderfl.net/user/Scmiz )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/to2m
*/
package {
import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.MouseEvent;
public class FlashTest extends Sprite {
public function FlashTest() {
redraw();
stage.addEventListener(MouseEvent.CLICK, onClick);
}
private function onClick(e:MouseEvent):void {
redraw();
}
private function redraw():void {
var g:Graphics = this.graphics;
g.clear();
var colorA:uint = createColor();
var colorB:uint = createColor();
while (colorB == colorA) {
colorB = createColor();
}
var gridSize:uint = Math.random() * 28 + 4;
var num:uint = (465 / gridSize) + 1;
for (var x:uint = 0; x < num; ++x) {
for (var y:uint = 0; y < num; ++y) {
g.beginFill(((x + y) % 2) == 0 ? colorA : colorB);
g.drawRect(gridSize * x, gridSize * y, gridSize, gridSize);
g.endFill();
}
}
}
private function createColor():uint {
var r:uint = 128 + Math.random() * 128;
var g:uint = 128 + Math.random() * 128;
var b:uint = 128 + Math.random() * 128;
return (r << 16) + (g << 8) + (b << 0);
}
}
}