forked from: forked from: hyperdiscosquares
Messing around
/**
* Copyright PrettyMuchBryce ( http://wonderfl.net/user/PrettyMuchBryce )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/cVGO
*/
// forked from PrettyMuchBryce's forked from: hyperdiscosquares
// forked from PrettyMuchBryce's hyperdiscosquares
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 = 1;
public function FlashTest() {
_buffer = new Bitmap(new BitmapData(500,500,false,0x0),"auto",false);
_squares = new Vector.<Square>(10000);
addEventListener(Event.ENTER_FRAME,update);
addChild(_buffer);
rotationX = -45;
_buffer.x=-50;
for (var i:int = 0; i < 500/5; i++) {
for (var j:int = 0; j < 500/5; j++) {
_squares[(i*100)+j]=new Square(i*5,j*5);
}
}
_squares[10000].colorize();
}
public function update(e:Event):void {
_tick++;
if (_tick > _tickMax) {
for (var i:int=0; i < 9999; i++) {
//_squares[i].colorize();
_squares[i].blendColor(_squares[i+1].myColor);
_squares[i].render(_buffer.bitmapData);
}
_squares[9999].colorize();
_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 {
public 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,5,5);
colorize();
}
public function colorize():void {
myColor = Math.random()*0xFFFFFF;
}
public function blendColor(color:uint):void {
myColor = color+1000;
}
public function render(target:BitmapData):void {
target.fillRect(rect,myColor);
}
}