Frame 1
function createGrid() {
grid = new Array();
y = 0;
while (y < 15) {
var _local1 = new Array();
x = 0;
while (x < 25) {
mc = attachMovie("gridbox", (("gridbox " + x) + " ") + y, (y * 25) + x);
mc._x = (x * 20) + 30;
mc._y = (y * 20) + 30;
mc.x = x;
mc.y = y;
_local1.push(false);
x++;
}
grid.push(_local1);
y++;
}
}
function cycle() {
var _local2 = this;
var _local1 = duplicateGrid();
y = 0;
while (y < 15) {
x = 0;
while (x < 25) {
thisBox = _local1[y][x];
mc = _local2[(("gridbox " + x) + " ") + y];
n = 0;
n = n + _local1[y - 1][x - 1];
n = n + _local1[y - 1][x];
n = n + _local1[y - 1][x + 1];
n = n + _local1[y][x - 1];
n = n + _local1[y][x + 1];
n = n + _local1[y + 1][x - 1];
n = n + _local1[y + 1][x];
n = n + _local1[y + 1][x + 1];
if (thisBox) {
if ((n == 2) or (n == 3)) {
newValue = true;
} else {
newValue = false;
}
} else if (n == 3) {
newValue = true;
} else {
newValue = false;
}
grid[y][x] = newValue;
if (newValue) {
mc.gotoAndStop(2);
} else {
mc.gotoAndStop(1);
}
x++;
}
y++;
}
}
function duplicateGrid() {
var _local2 = new Array();
y = 0;
while (y < 15) {
var _local1 = new Array();
x = 0;
while (x < 25) {
_local1.push(grid[y][x]);
x++;
}
_local2.push(_local1);
y++;
}
return(_local2);
}
function runCycle() {
if (running) {
cycle();
}
}
function startCycle() {
running = true;
}
function stepCycle() {
cycle();
}
function stopCycle() {
running = false;
}
function clear() {
var _local1 = this;
y = 0;
while (y < 15) {
x = 0;
while (x < 25) {
grid[y][x] = 0;
_local1[(("gridbox " + x) + " ") + y].gotoAndStop(1);
x++;
}
y++;
}
running = false;
}
createGrid();
stop();
Instance of Symbol 11 MovieClip in Frame 1
onClipEvent (enterFrame) {
_parent.runCycle();
}
Symbol 3 Button
on (release) {
if (_currentframe == 1) {
gotoAndStop (2);
_parent.grid[y][x] = true;
} else {
gotoAndStop (1);
_parent.grid[y][x] = false;
}
}
Symbol 5 MovieClip [gridbox] Frame 1
stop();
Symbol 9 Button
on (release) {
startCycle();
}
Symbol 13 Button
on (release) {
stepCycle();
}
Symbol 15 Button
on (release) {
clear();
}
Symbol 17 Button
on (release) {
stopCycle();
}