Frame 1
function effect() {
bitmap.draw(farm);
bitmap.applyFilter(bitmap, rect, point, blur);
}
var blur = (new flash.filters.BlurFilter(2, 2, 3));
var glow = (new flash.filters.GlowFilter(16777215, 1, 4, 4, 2, 3, false, false));
var bitmap = (new flash.display.BitmapData(250, 250, false, 0));
var point = (new flash.geom.Point(0, 0));
var rect = (new flash.geom.Rectangle(0, 0, 250, 250));
_root.createEmptyMovieClip("bitlayer", 5);
_root.bitlayer.attachBitmap(bitmap, 8);
farm._visible = false;
setInterval(effect, 10);
Symbol 5 MovieClip [crystal_blue] Frame 10
this.removeMovieClip();
Symbol 9 MovieClip [crystal_purp] Frame 10
this.removeMovieClip();
Symbol 11 MovieClip [CrystalFarm] Frame 1
#initclip 2
Object.registerClass("CrystalFarm", CrystalFarm);
#endinitclip
Symbol 12 MovieClip [__Packages.CrystalFarm] Frame 0
class CrystalFarm extends MovieClip
{
var attachMovie, cwidth, cheight, mcs, _width, _height, _xscale, _yscale, __width, __height, cols, rows, onMouseUp, grid, active, onEnterFrame, _xmouse, _ymouse;
function CrystalFarm () {
super();
var _local3 = attachMovie(CRYSTAL_LINKAGE, "tmp", 1);
cwidth = _local3._width;
cheight = _local3._height;
_local3.removeMovieClip();
mcs = [];
}
function onLoad() {
var _local2 = _width;
var _local3 = _height;
_xscale = (_yscale = 100);
setSize(_local2, _local3);
}
function setSize(p_width, p_height) {
__width = p_width;
__height = p_height;
cols = Math.ceil(__width / cwidth);
rows = Math.ceil(__height / cheight);
onMouseUp = startClick;
}
function reset() {
grid = [];
var _local4 = cols;
var _local3;
while (_local4--) {
_local3 = (grid[_local4] = []);
var _local2 = rows;
while (_local2--) {
_local3[_local2] = random(190) + 10;
}
}
while (mcs.length) {
mcs.pop().removeMovieClip();
}
active = {};
delete onEnterFrame;
}
function startClick() {
reset();
activate(Math.max(1, Math.min(cols - 2, Math.floor(_xmouse / cwidth))), Math.max(1, Math.min(rows - 2, Math.floor(_ymouse / cheight))));
delete onMouseUp;
onEnterFrame = doIdle;
}
function doIdle() {
var _local4 = [];
for (var _local6 in active) {
var _local2 = active[_local6].x;
var _local3 = active[_local6].y;
grid[_local2][_local3] = grid[_local2][_local3] - (random(6) / 2);
if (grid[_local2][_local3] < 0) {
_local4.push(active[_local6]);
}
}
var _local5 = _local4.length;
while (_local5--) {
activate(_local4[_local5].x, _local4[_local5].y);
}
if (mcs.length == (cols * rows)) {
delete onEnterFrame;
onMouseUp = startClick;
}
}
function activate(p_x, p_y) {
if (random(2) == 0) {
CRYSTAL_LINKAGE = "crystal_blue";
} else {
CRYSTAL_LINKAGE = "crystal_purp";
}
grid[p_x][p_y] = 0;
var _local4 = (p_y * cols) + p_x;
delete active["_" + _local4];
mcs.push(attachMovie(CRYSTAL_LINKAGE, "c" + _local4, _local4, {_x:p_x * cwidth, _y:p_y * cheight, id:_local4, x:p_x, y:p_y}));
if (grid[p_x - 1][p_y] > 0) {
grid[p_x - 1][p_y] = grid[p_x - 1][p_y] - (5 + random(140));
active["_" + (_local4 - 1)] = {x:p_x - 1, y:p_y};
}
if (grid[p_x + 1][p_y] > 0) {
grid[p_x + 1][p_y] = grid[p_x + 1][p_y] - (5 + random(140));
active["_" + (_local4 + 1)] = {x:p_x + 1, y:p_y};
}
if (grid[p_x][p_y - 1] > 0) {
grid[p_x][p_y - 1] = grid[p_x][p_y - 1] - (5 + random(140));
active["_" + (_local4 - cols)] = {x:p_x, y:p_y - 1};
}
if (grid[p_x][p_y + 1] > 0) {
grid[p_x][p_y + 1] = grid[p_x][p_y + 1] - (5 + random(140));
active["_" + (_local4 + cols)] = {x:p_x, y:p_y + 1};
}
}
var CRYSTAL_LINKAGE = "crystal_purp";
}