hyperdiscosquares
/**
* Copyright PrettyMuchBryce ( http://wonderfl.net/user/PrettyMuchBryce )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qbPd
*/
package {
//Messing around
import flash.display.Sprite;
import flash.events.Event;
import flash.display.Bitmap;
import flash.display.BitmapData;
[ SWF (width = '400', height = '500', backgroundColor = '0x000000', frameRate = '60')]
public class FlashTest extends Sprite {
private var _squares:Vector.<Square>;
private var _buffer:Bitmap;
private var _tick:int = 0;
private const _tickMax:int = 15;
public function FlashTest() {
_buffer = new Bitmap(new BitmapData(500,500,false,0x0),"auto",false);
_squares = new Vector.<Square>(100);
addEventListener(Event.ENTER_FRAME,update);
addChild(_buffer);
_buffer.x=-50;
for (var i:int = 0; i < 500/50; i++) {
for (var j:int = 0; j < 500/50; j++) {
_squares[(i*10)+j]=new Square(i*50,j*50);
}
}
}
public function update(e:Event):void {
_tick++;
if (_tick > _tickMax) {
for (var i:int=0; i < 100; i++) {
_squares[i].colorize();
_squares[i].render(_buffer.bitmapData);
}
_tick = 0;
}
}
}
}
import flash.display.AVM1Movie;
import flash.display.Shape;
import flash.geom.Rectangle;
import flash.display.Sprite;
import flash.display.BitmapData;
internal class Square {
private var myColor:uint;
private var x:Number;
private var y:Number;
private var rect:Rectangle;
public function Square(X:Number,Y:Number):void {
x = X;
y = Y;
rect = new Rectangle(x,y,50,50);
colorize();
}
public function colorize():void {
myColor = Math.random()*0xFFFFFF;
}
public function render(target:BitmapData):void {
target.fillRect(rect,myColor);
}
}