Combined Code
movieClip 3 Cube5 {
frame 1 {
stop();
}
frame 2 {
stop();
}
}
movieClip 6 Cube4 {
frame 1 {
stop();
}
frame 2 {
stop();
}
}
movieClip 9 Cube3 {
frame 1 {
stop();
}
frame 2 {
stop();
}
}
movieClip 12 Cube2 {
frame 1 {
stop();
}
frame 2 {
stop();
}
}
movieClip 15 Cube1 {
frame 1 {
stop();
}
frame 2 {
stop();
}
}
movieClip 16 Cube5 {
frame 1 {
stop();
}
frame 2 {
stop();
}
}
movieClip 17 Cube4 {
frame 1 {
stop();
}
frame 2 {
stop();
}
}
movieClip 18 Cube3 {
frame 1 {
stop();
}
frame 2 {
stop();
}
}
movieClip 19 Cube2 {
frame 1 {
stop();
}
frame 2 {
stop();
}
}
movieClip 20 Cube1 {
frame 1 {
stop();
}
frame 2 {
stop();
}
}
frame 1 {
tellTarget ('_level0') {
lbLoadingGame = '';
}
}
movieClip 24 {
}
frame 3 {
if (_framesloaded >= _totalframes) {
gotoAndPlay(4);
} else {
gotoAndPlay(2);
}
}
frame 4 {
function NewGame() {
wndSaveScore._visible = false;
stScore = '0';
var n = 0;
while (n < NumX * NumY) {
if (Board[n]) {
removeMovieClip(Selected[i]);
}
++n;
}
var n = 0;
Colors = [0, 0, 0, 0, 0, 0];
var j = 0;
while (j < NumY) {
var i = 0;
while (i < NumX) {
var color = 1 + random(5);
var name = 'Cube_' + n;
++Colors[color];
attachMovie('Cube' + color, name, n);
var c = eval(name);
Board[n] = c;
c._height = Size;
c._width = c._height;
c._x = i * c._width;
c._y = j * c._height;
c.color = color;
c.was = false;
++n;
++i;
}
++j;
}
num1 = Colors[1];
num2 = Colors[2];
num3 = Colors[3];
num4 = Colors[4];
num5 = Colors[5];
}
function Select(x, y) {
var c = Board[x + y * NumX];
if (PrevX == x and PrevY == y) {
return undefined;
}
var i = 0;
while (i < Selected.length) {
Selected[i].gotoAndStop(1);
Selected[i].was = false;
++i;
}
Selected = [];
if (!c) {
stNumSelect = '';
PrevX = x;
PrevY = y;
return 0;
}
var num = Paint(x, y, c.color);
if (1 < num) {
stNumSelect = Fib[num];
} else {
stNumSelect = '';
var i = 0;
while (i < Selected.length) {
Selected[i].gotoAndStop(1);
Selected[i].was = false;
++i;
}
Selected = [];
}
PrevX = x;
PrevY = y;
}
function Paint(x, y, color) {
if (x < 0 or x >= NumX) {
return 0;
}
if (y < 0 or y >= NumY) {
return 0;
}
var c = Board[x + y * NumX];
if (!c) {
return 0;
}
if (c.color != color) {
return 0;
}
if (c.was) {
return 0;
}
c.gotoAndStop(2);
c.was = true;
Selected.push(c);
var n = 1;
n += Paint(x + 1, y, color);
n += Paint(x, y + 1, color);
n += Paint(x - 1, y, color);
n += Paint(x, y - 1, color);
return n;
}
function UnvisiblePaint(x, y, color) {
if (x < 0 or x >= NumX) {
return 0;
}
if (y < 0 or y >= NumY) {
return 0;
}
var c = Board[x + y * NumX];
if (!c) {
return 0;
}
if (c.color != color) {
return 0;
}
if (c.was) {
return 0;
}
c.was = true;
Selected.push(c);
var n = 1;
n += UnvisiblePaint(x + 1, y, color);
n += UnvisiblePaint(x, y + 1, color);
n += UnvisiblePaint(x - 1, y, color);
n += UnvisiblePaint(x, y - 1, color);
return n;
}
function Delete() {
if (Selected.length < 2) {
return 0;
}
var color = Selected[0].color;
if (color == 1) {
num1 = Number(num1) - Selected.length;
} else {
if (color == 2) {
num2 = Number(num2) - Selected.length;
} else {
if (color == 3) {
num3 = Number(num3) - Selected.length;
} else {
if (color == 4) {
num2 = Number(num4) - Selected.length;
} else {
if (color == 5) {
num2 = Number(num5) - Selected.length;
}
}
}
}
}
stScore = Number(stScore) + Fib[Selected.length];
var i = 0;
while (i < Selected.length) {
var x = int((Selected[i]._x + 1) / Size);
var y = int((Selected[i]._y + 1) / Size);
var n = x + y * NumX;
removeMovieClip(Selected[i]);
Board[n] = '';
var j = y - 1;
while (j >= 0) {
Board[n] = Board[n - NumX];
if (!Board[n]) {
break;
}
Board[n]._y = (j + 1) * Size;
n -= NumX;
Board[n] = '';
--j;
}
++i;
}
Selected = [];
var n = NumY * NumX - 1;
var i = NumX - 1;
while (i >= 0) {
if (!Board[n]) {
Compress(i);
}
--n;
--i;
}
if (EndGame()) {
wndSaveScore._visible = true;
return undefined;
}
var i = 0;
while (i < Selected.length) {
Selected[i].was = false;
++i;
}
Selected = [];
PrevY = -1;
PrevX = -1;
return k + 1;
}
function Compress(x) {
var i = x + 1;
while (i < NumX) {
var n2 = i + (NumY - 1) * NumX;
var newX = (i - 1) * Size;
var j = NumY - 1;
while (j >= 0) {
n1 = n2 - 1;
if (!Board[n2]) {
Board[n1] = '';
if (j == NumY - 1) {
return undefined;
} else {
break;
}
}
Board[n1] = Board[n2];
Board[n1]._x = newX;
Board[n2] = '';
n2 -= NumX;
--j;
}
++i;
}
}
function EndGame() {
var y = NumY - 1;
while (y >= 0) {
var n = y * NumX;
var sum = 0;
var x = 0;
while (x < NumX) {
if (!Board[n]) {
++sum;
++n;
} else {
if (1 < UnvisiblePaint(x, y, Board[n].color)) {
return false;
}
++n;
}
++x;
}
if (sum == NumX) {
return true;
}
--y;
}
return true;
}
function Crypto(st) {
var sum1 = 0;
var sum2 = 0;
var i = 0;
while (i < st.length) {
sum1 += st.charCodeAt(i);
sum2 += st.charCodeAt(i) ^ 175;
++i;
}
sum1 %= 256;
sum2 %= 256;
st = String.fromCharCode(sum1) + String.fromCharCode(sum2) + st;
var cryptSt = '';
var b0 = 193;
var i = 0;
while (i < st.length) {
var b = st.charCodeAt(i);
var CryptB = b ^ b0;
CryptB = CryptB.toString();
var len = CryptB.length;
var j = 0;
while (j < 3 - len) {
CryptB = '0' + CryptB;
++j;
}
cryptSt += CryptB;
b0 = b;
++i;
}
return cryptSt;
}
if (init) {
return undefined;
} else {
init = true;
}
Width = 375;
Height = 375;
Size = 25;
NumX = int(Width / Size);
NumY = int(Height / Size);
PrevColor = 0;
Board = new Array(NumX * NumY);
Selected = new Array();
Colors = new Array(6);
Fib = new Array(70);
Fib[1] = 1;
Fib[0] = 1;
var n = 2;
while (n < 70) {
Fib[n] = int(n * n * n / 3);
++n;
}
NewGame();
}
button 26 {
on (release) {
var x = int(_xmouse / Size);
var y = int(_ymouse / Size);
if (x < 0 or x >= NumX) {
return 0;
}
if (y < 0 or y >= NumY) {
return 0;
}
if (Board[x + y * NumX]) {
Delete();
}
}
}
button 52 {
on (release) {
NewGame();
}
}
button 57 {
on (release) {
var stSend = _parent.stScore + '\t' + 1 + '\t' + stName + '\t' + 'sqr' + '\t' + 'web';
getURL('http://absolutist.com/cgi-bin/gameres.pl?e=' + _parent.Crypto(stSend), '_top');
trace(stName + ' = ' + _parent.stScore);
_visible = false;
_parent.NewGame();
}
}
button 58 {
on (release) {
_visible = false;
_parent.NewGame();
}
}
movieClip 61 {
}
frame 6 {
if (Width < _xmouse or _xmouse < 0 or (Height < _ymouse or _ymouse < 0)) {
var i = 0;
while (i < Selected.length) {
Selected[i].gotoAndPlay(1);
Selected[i].was = false;
PrevY = -1;
PrevX = -1;
++i;
}
Selected = [];
gotoAndPlay(5);
return undefined;
}
var x = int(_xmouse / Size);
var y = int(_ymouse / Size);
Select(x, y);
gotoAndPlay(5);
}