ひたすら面が描かれる
ただひたすら面が描かれる
/**
ただひたすら面が描かれる
*/
package {
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.geom.Point;
import flash.geom.Rectangle;
//import caurina.transitions.Tweener;
public class Graph03_2 extends Sprite {
private const INTERVAL:Number = 0.02;
private const TICKS:uint = 1000;
private const END:uint = 500;
private var timer:Timer;
private var STAGERECT:Point;
private var d:Rectangle;
private var scene:Sprite;
public function Graph03_2() {
init();
}
private function init():void {
STAGERECT = new Point(stage.stageWidth, stage.stageHeight);
scene = new Sprite();
addChild(scene);
timer = new Timer(INTERVAL*TICKS, END);
timer.addEventListener(TimerEvent.TIMER, tHandler);
timer.start();
}
private function tHandler(e:TimerEvent = null):void {
resizeRect();
scene.graphics.beginFill(getRandomColor(), 0.1);
scene.graphics.drawRect(d.x, d.y, d.width, d.height);
scene.graphics.endFill();
}
private function resizeRect():void {
d = new Rectangle(
getRandom(STAGERECT.x),
getRandom(STAGERECT.y),
getRandom(STAGERECT.x),
getRandom(STAGERECT.y)
);
}
public static function getRandom(__range:uint):uint {
return Math.floor(Math.random() * __range);
}
public static function getRandomColor(__range:uint = 0x100):uint {
return (getRandom(__range) << 16 | getRandom(__range) << 8 | getRandom(__range));
}
}
}