flash on 2012-12-1
/**
* Copyright yonatan ( http://wonderfl.net/user/yonatan )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/d22Q
*/
package {
import flash.display.*;
import flash.events.*;
public class main extends Sprite {
private var bmd:BitmapData = new BitmapData(465, 465, false, 0);
private var bmp:Bitmap = new Bitmap(bmd);
private var _x:int = 0, _y:int = 0, dsq:int = 0;
function main():void {
addChild(bmp);
addEventListener("enterFrame", frame);
}
private function frame(e:Event):void {
for(var i:int = 0; i < 1000; i++) tick();
}
private function tick():void {
bmd.setPixel(232+_x, 232+_y, dsq);
var dir:int = Math.random()*4;
switch(dir) {
case 0: if(_y>-200) { dsq = dsq - _y - _y + 1; _y--; } break;
case 1: if(_x< 200) { dsq = dsq + _x + _x + 1; _x++; } break;
case 2: if(_y< 200) { dsq = dsq + _y + _y + 1; _y++; } break;
case 3: if(_x>-200) { dsq = dsq - _x - _x + 1; _x--; } break;
}
}
}
}