Frame 1
if (getBytesLoaded() >= getBytesTotal()) {
gotoAndStop (3);
}
Frame 2
gotoAndPlay (1);
Frame 3
function cbFinished() {
_mvScriptYouWon.showS();
}
function clickB(caption) {
var nDim;
if (caption == "Begin") {
_mvScriptYouWon.hideS();
nDim = int(_txtDim);
_mvSquare.playGame(nDim);
}
if (caption == "Help") {
_mvSquare.helpGame();
}
}
var wmG = 550;
var hmG = 400;
Instance of Symbol 2 MovieClip in Frame 3
onClipEvent (load) {
_width = _parent.wmG;
_height = _parent.hmG;
_x = (_parent.wmG / 2);
_y = (_parent.hmG / 2);
}
Instance of Symbol 26 MovieClip "_mvCtrlV" in Frame 3
onClipEvent (load) {
_txtCaption = "Begin";
}
Instance of Symbol 26 MovieClip in Frame 3
onClipEvent (load) {
_txtCaption = "Help";
}
Instance of Symbol 30 MovieClip "_mvScriptYouWon" in Frame 3
onClipEvent (load) {
_y = _parent._mvSquare._y;
}
Symbol 9 MovieClip Frame 1
function buildZero(dimSq) {
var snm;
var _mvK;
var jm;
var nr;
var nc;
arrCoo = new Array(dimSq * dimSq);
jm = 0;
while (jm < (dimSq * dimSq)) {
snm = getNameSqS(++qDup);
duplicateMovieClip (_mvSqEmp, snm, qDup);
_mvJ = eval (snm);
nr = _parent.getNr(jm);
nc = _parent.getNc(jm);
_mvJ._x = ((((-dimSq) / 2) * _mvSqEmp._width) + (_mvSqEmp._width / 2)) + (nc * _mvSqEmp._width);
_mvJ._y = ((((-dimSq) / 2) * _mvSqEmp._height) + (_mvSqEmp._height / 2)) + (nr * _mvSqEmp._height);
arrCoo[2 * jm] = _mvJ._x;
arrCoo[(2 * jm) + 1] = _mvJ._y;
jm++;
}
arrSqS = new Array(qDup);
jm = 0;
while (jm < qDup) {
snm = getNameSqS(1 + jm);
_mvK = eval (snm);
arrSqS[jm] = _mvK;
jm++;
}
}
function getNameSqS(no) {
var snm;
snm = "_mvSqEmp" + no;
return(snm);
}
function deleteZero() {
delete arrSqS;
while (qDup > 0) {
snm = getNameSqS(qDup);
_mvK = eval (snm);
removeMovieClip(_mvK);
qDup--;
}
delete arrCoo;
}
var qDup = 0;
var arrCoo;
var arrSqS;
Instance of Symbol 8 MovieClip in Symbol 9 MovieClip Frame 1
onClipEvent (load) {
_visible = 0;
_parent._mvSqEmp._visible = 0;
}
Symbol 15 MovieClip Frame 1
function buildZero(nPart, nclK) {
var qPartsJ;
var qSq;
var nSq;
var jSq;
var nr;
var nc;
var nrB;
var ncB;
var snm;
var _mvJ;
var iRes;
var nDir;
qSq = _parent.dimSq * _parent.dimSq;
nSq = random(qSq);
(jSq = 0);
(iRes = 0);
while (jSq < qSq) {
if (_parent.arrSqDD[nSq] == 0) {
iRes = 1;
break;
}
if ((++nSq) >= qSq) {
nSq = 0;
}
jSq++;
}
if (iRes) {
_parent.arrSqDD[nSq] = 1;
nrB = (nr = _parent.getNr(nSq));
ncB = (nc = _parent.getNc(nSq));
_x = (((((-_parent.dimSq) / 2) * _mvSquareS._width) + (_mvSquareS._width / 2)) + (ncB * _mvSquareS._width));
_y = (((((-_parent.dimSq) / 2) * _mvSquareS._height) + (_mvSquareS._height / 2)) + (nrB * _mvSquareS._height));
snm = getNameSqS(++qDup);
duplicateMovieClip (_mvSquareS, snm, qDup);
_mvJ = eval (snm);
_mvJ._x = (nc - ncB) * _mvSquareS._width;
_mvJ._y = (nr - nrB) * _mvSquareS._height;
qPartsJ = _parent.dimSq + random(1);
jSq = 1;
while (jSq < qPartsJ) {
nDir = nextSquareC(nSq);
if (nDir == -1) {
break;
}
if (nDir == 0) {
nSq++;
}
if (nDir == 1) {
nSq = nSq + _parent.dimSq;
}
if (nDir == 2) {
nSq--;
}
if (nDir == 3) {
nSq = nSq - _parent.dimSq;
}
_parent.arrSqDD[nSq] = 1;
nr = _parent.getNr(nSq);
nc = _parent.getNc(nSq);
snm = getNameSqS(++qDup);
duplicateMovieClip (_mvSquareS, snm, qDup);
_mvJ = eval (snm);
_mvJ._x = (nc - ncB) * _mvSquareS._width;
_mvJ._y = (nr - nrB) * _mvSquareS._height;
jSq++;
}
arrCoo = new Array(qDup * 2);
arrSqS = new Array(qDup);
jSq = 0;
while (jSq < qDup) {
snm = getNameSqS(1 + jSq);
_mvJ = eval (snm);
arrSqS[jSq] = _mvJ;
jSq++;
}
}
colorSq(nclK);
doDull();
return(iRes);
}
function getNameSqS(no) {
var snm;
snm = "_mvSquareS" + no;
return(snm);
}
function colorSq(ncl) {
var jm;
var snm;
var _mvJ;
var clK;
jm = 1;
while (jm <= qDup) {
ncl = int(ncl);
snm = getNameSqS(jm);
_mvJ = eval (snm);
clK = new Color(_mvJ._mvSquareSInt);
clK.setRGB(ncl);
delete clK;
jm++;
}
}
function getColor() {
var clK;
var snm;
var nclRes;
snm = getNameSqS(1);
_mvJ = eval (snm);
clK = new Color(_mvJ._mvSquareSInt);
nclRes = clK.getRGB();
delete clK;
return(nclRes);
}
function nextSquareC(nSq) {
var nd;
var jd;
var iFnd;
var nSqN;
nd = random(4);
(jd = 0);
(iFnd = 0);
while ((jd < 4) && (!iFnd)) {
if (nd == 0) {
nSqN = nSq + 1;
if ((nSqN % _parent.dimSq) != 0) {
if (!_parent.arrSqDD[nSqN]) {
iFnd = 1;
}
}
}
if (nd == 1) {
nSqN = nSq + _parent.dimSq;
if (nSqN < (_parent.dimSq * _parent.dimSq)) {
if (!_parent.arrSqDD[nSqN]) {
iFnd = 1;
}
}
}
if (nd == 2) {
nSqN = nSq - 1;
if (((nSqN + 1) % _parent.dimSq) != 0) {
if (!_parent.arrSqDD[nSqN]) {
iFnd = 1;
}
}
}
if (nd == 3) {
nSqN = nSq - _parent.dimSq;
if (nSqN >= 0) {
if (!_parent.arrSqDD[nSqN]) {
iFnd = 1;
}
}
}
if (iFnd) {
break;
}
if ((++nd) >= 4) {
nd = 0;
}
jd++;
}
if (!iFnd) {
nd = -1;
}
return(nd);
}
function deleteZero() {
delete arrSqS;
while (qDup > 0) {
snm = getNameSqS(qDup);
_mvK = eval (snm);
removeMovieClip(_mvK);
qDup--;
}
delete arrCoo;
}
function fillArrCoo(_mvPt) {
var jSq;
jSq = 0;
while (jSq < _mvPt.qDup) {
arrCoo[2 * jSq] = _mvPt._x + _mvPt.arrSqS[jSq]._x;
arrCoo[(2 * jSq) + 1] = _mvPt._y + _mvPt.arrSqS[jSq]._y;
jSq++;
}
}
function doShine() {
var jSq;
jSq = 0;
while (jSq < qDup) {
arrSqS[jSq]._mvSquareSBnd._visible = 1;
jSq++;
}
}
function doDull() {
var jSq;
jSq = 0;
while (jSq < qDup) {
arrSqS[jSq]._mvSquareSBnd._visible = 0;
jSq++;
}
}
var nDup;
var qDup = 0;
var iDrag = 0;
var dx;
var dy;
var arrCoo;
var arrSqS;
var iShine = -1;
Instance of Symbol 8 MovieClip in Symbol 15 MovieClip Frame 1
onClipEvent (load) {
_visible = 0;
_parent._mvSquareS._visible = 0;
}
Symbol 16 MovieClip Frame 1
function playGame(dimSq_) {
var snm;
var _mvK;
if (dimSq != null) {
delete arrBCoo;
delete arrCCoo;
while (qDup > 0) {
snm = getNameSqS(qDup);
_mvK = eval (snm);
_mvK.deleteZero();
removeMovieClip(_mvK);
qDup--;
}
_mvSqEmpD.deleteZero();
delete arrSqDD;
}
dimSq = dimSq_;
arrSqDD = new Array(dimSq * dimSq);
iAs = 0;
nRun = 1;
return(1);
}
function buildZero() {
var iRes;
var snm;
var _mvK;
var jSq;
if (iBuilt) {
(jSq = 0);
(iRes = 0);
while (jSq < arrSqDD.length) {
if (arrSqDD[jSq] == 0) {
iRes = 1;
break;
}
jSq++;
}
if (iRes) {
snm = getNameSqS(++qDup);
duplicateMovieClip (_mvSqPart, snm, qDup);
}
iBuilt = 0;
} else {
snm = getNameSqS(qDup);
_mvK = eval (snm);
_mvK.nDup = qDup;
_mvK.buildZero(qDup, nclKPt);
nclKPt = nextColor(nclKPt);
iBuilt = 1;
iRes = 1;
}
return(iRes);
}
function getNameSqS(no) {
var snm;
snm = "_mvSqPart" + no;
return(snm);
}
function timeFlies() {
var iRes;
var jSq;
var jPt;
var snm;
var _mvPt;
if (nRun == 7) {
}
if (nRun == 6) {
_parent.cbFinished();
nRun++;
}
if (nRun == 5) {
iRes = showYouWon();
if (iRes) {
nRun++;
}
}
if ((nRun == 4) || (nRun == 4.5)) {
if (nRun == 4) {
iRes = watchResult();
if (iRes) {
nRun++;
}
}
if (nRun == 4.5) {
if (iAs == 2) {
iAs = assemble(arrCCoo, iAs);
if (!iAs) {
nRun = 4;
}
}
if (iAs == 1) {
iAs = assemble(arrBCoo, iAs);
if (iAs == 0) {
iAs = 2;
}
}
}
}
if (nRun == 3) {
iRes = disassemble(0);
if (!iRes) {
nRun++;
}
}
if (nRun == 2) {
iRes = buildZero();
if (!iRes) {
arrBCoo = new Array(qDup * 2);
arrCCoo = new Array(qDup * 2);
jPt = 0;
while (jPt < qDup) {
snm = getNameSqS(1 + jPt);
_mvPt = eval (snm);
arrCCoo[2 * jPt] = (arrBCoo[2 * jPt] = _mvPt._x);
arrCCoo[(2 * jPt) + 1] = (arrBCoo[(2 * jPt) + 1] = _mvPt._y);
jPt++;
}
disassemble(1);
nRun++;
}
}
if (nRun == 1) {
_mvSqEmpD._x = _mvSqPart._x;
_mvSqEmpD._y = _mvSqPart._y;
_mvSqEmpD.buildZero(dimSq);
jSq = 0;
while (jSq < arrSqDD.length) {
arrSqDD[jSq] = 0;
jSq++;
}
qParts = 0;
iBuilt = -1;
nclKPt = 0;
nRun++;
}
}
function getNr(nSq) {
var nr;
nr = int(nSq / dimSq);
return(nr);
}
function getNc(nSq) {
var nc;
nc = nSq % dimSq;
return(nc);
}
function nextColor(ncl) {
var ncl;
var nclR;
var nclG;
var nclB;
var qpD = 256;
ncl = int(ncl);
nclB = ncl - (int(ncl / 256) * 256);
ncl = int(ncl / 256);
nclG = ncl - (int(ncl / 256) * 256);
nclR = int(ncl / 256);
if (nclB == 255) {
nclB = 0;
if (nclG == 255) {
nclG = 0;
if (nclR == 255) {
nclR = 0;
} else {
nclR = nclR + qpD;
if (nclR > 255) {
nclR = 255;
}
}
} else {
nclG = nclG + qpD;
if (nclG > 255) {
nclG = 255;
}
}
} else {
nclB = nclB + qpD;
if (nclB > 255) {
nclB = 255;
}
}
ncl = (((nclR * 256) * 256) + (nclG * 256)) + nclB;
return(ncl);
}
function disassemble(ib) {
var ja;
var jPt;
var snm;
var _mvK;
var dJ;
var dMax;
var iRes;
var wmA;
var hmA;
var wmW;
var hmW;
var wmWS;
var hmWS;
var xr;
var yr;
var ir;
if (ib) {
arrPD = new Array(qDup * 2);
wmWS = _mvSqEmpD._mvSqEmp._width;
hmWS = _mvSqEmpD._mvSqEmp._height;
wmW = dimSq * wmWS;
hmW = dimSq * hmWS;
wmWS = wmWS * 3;
hmWS = hmWS * 3;
wmA = _root.wmG - (wmWS * 4);
hmA = _root.hmG - (hmWS * 4);
ja = 0;
while (ja < qDup) {
xr = random(wmA) - (wmA / 2);
if (((((-wmW) / 2) - wmWS) <= xr) && (xr <= ((wmW / 2) + wmWS))) {
yr = ((hmW / 2) + hmWS) + random(((hmA / 2) - (hmW / 2)) - hmWS);
ir = random(2);
if (ir) {
yr = -yr;
}
} else {
yr = random(hmA) - (hmA / 2);
}
arrPD[ja * 2] = xr;
arrPD[(ja * 2) + 1] = yr;
ja++;
}
}
(jPt = 0);
(dMax = 0);
while (jPt < qDup) {
snm = getNameSqS(1 + jPt);
_mvK = eval (snm);
_mvK._x = (_mvK._x + arrPD[jPt * 2]) / 2;
_mvK._y = (_mvK._y + arrPD[(jPt * 2) + 1]) / 2;
dJ = Math.sqrt(((arrPD[jPt * 2] - _mvK._x) * (arrPD[jPt * 2] - _mvK._x)) + ((arrPD[(jPt * 2) + 1] - _mvK._y) * (arrPD[(jPt * 2) + 1] - _mvK._y)));
if (dJ > dMax) {
dMax = dJ;
}
jPt++;
}
if (dMax > 2) {
iRes = 1;
} else {
delete arrPD;
iRes = 0;
}
return(iRes);
}
function testTouchUpper(nDup) {
var iRes;
var jPt;
var snm;
var _mvK;
(jPt = (nDup - 1) + 1);
(iRes = 0);
while (jPt < qDup) {
snm = getNameSqS(1 + jPt);
_mvK = eval (snm);
if (_mvK.hitTest(_root._xmouse, _root._ymouse, 1)) {
iRes = 1;
break;
}
jPt++;
}
return(iRes);
}
function defineShine(_mvPt) {
var jSq;
var jSqEm;
var iShine;
var iShineJ;
var dx;
var dy;
var nZero;
dx = _mvSqEmpD._mvSqEmp._width / 3;
dy = _mvSqEmpD._mvSqEmp._height / 3;
(jSq = 0);
(iShine = 1);
while (jSq < _mvPt.qDup) {
(jSqEm = 0);
(iShineJ = 0);
while (jSqEm < _mvSqEmpD.qDup) {
if (((((_mvSqEmpD.arrCoo[2 * jSqEm] - dx) <= _mvPt.arrCoo[2 * jSq]) && (_mvPt.arrCoo[2 * jSq] <= (_mvSqEmpD.arrCoo[2 * jSqEm] + dx))) && ((_mvSqEmpD.arrCoo[(2 * jSqEm) + 1] - dy) <= _mvPt.arrCoo[(2 * jSq) + 1])) && (_mvPt.arrCoo[(2 * jSq) + 1] <= (_mvSqEmpD.arrCoo[(2 * jSqEm) + 1] + dy))) {
iShineJ = 1;
if (jSq == 0) {
nZero = jSqEm;
}
break;
}
jSqEm++;
}
if (!iShineJ) {
iShine = 0;
break;
}
jSq++;
}
if (!iShine) {
nZero = -1;
}
return(nZero);
}
function placePart(_mvPt, nEmp) {
_mvPt._x = _mvSqEmpD.arrSqS[nEmp]._x;
_mvPt._y = _mvSqEmpD.arrSqS[nEmp]._y;
}
function watchResult() {
var iRes;
var jSqEm;
var jPt;
var jSq;
var snm;
var _mvPt;
var iCoi;
(jSqEm = 0);
(iRes = 1);
while (jSqEm < _mvSqEmpD.qDup) {
jPt = 1;
while (jPt <= qDup) {
snm = getNameSqS(jPt);
_mvPt = eval (snm);
(jSq = 0);
(iCoi = 0);
while (jSq < _mvPt.qDup) {
if (_mvSqEmpD.arrSqS[jSqEm]._mvSqEmpKern.hitTest(_mvPt.arrSqS[jSq])) {
iCoi = 1;
break;
}
jSq++;
}
if (iCoi) {
break;
}
jPt++;
}
if (!iCoi) {
iRes = 0;
break;
}
jSqEm++;
}
if (iRes) {
jPt = 1;
while (jPt <= qDup) {
snm = getNameSqS(jPt);
_mvPt = eval (snm);
if (_mvPt.iShine == -1) {
iRes = 0;
break;
}
jPt++;
}
}
if (iRes) {
jPt = 1;
while (jPt <= qDup) {
snm = getNameSqS(jPt);
_mvPt = eval (snm);
if (_mvPt.iDrag) {
iRes = 0;
break;
}
jPt++;
}
}
return(iRes);
}
function showYouWon() {
var jPt;
var snm;
var ncl;
var nclE = 16711680;
var nclR;
var nclG;
var nclB;
var nclER;
var nclEG;
var nclEB;
var iRes;
nclEB = nclE - (int(nclE / 256) * 256);
nclE = int(nclE / 256);
nclEG = nclE - (int(nclE / 256) * 256);
nclER = int(nclE / 256);
(jPt = 1);
(iRes = 1);
while (jPt <= qDup) {
snm = getNameSqS(jPt);
_mvPt = eval (snm);
ncl = _mvPt.getColor();
nclB = ncl - (int(ncl / 256) * 256);
ncl = int(ncl / 256);
nclG = ncl - (int(ncl / 256) * 256);
nclR = int(ncl / 256);
nclR = int(((4 * nclR) + nclER) / 5);
nclG = int(((4 * nclG) + nclEG) / 5);
nclB = int(((4 * nclB) + nclEB) / 5);
if (((Math.abs(nclR - nclER) > 5) || (Math.abs(nclG - nclEG) > 5)) || (Math.abs(nclB - nclEB) > 5)) {
iRes = 0;
} else {
nclR = nclER;
nclG = nclEG;
nclB = nclEB;
}
ncl = (((nclR * 256) * 256) + (nclG * 256)) + nclB;
_mvPt.colorSq(ncl);
jPt++;
}
return(iRes);
}
function helpGame() {
var jPt;
var snm;
var _mvPt;
if (nRun != 4) {
return(undefined);
}
jPt = 0;
while (jPt < qDup) {
snm = getNameSqS(1 + jPt);
_mvPt = eval (snm);
arrCCoo[2 * jPt] = _mvPt._x;
arrCCoo[(2 * jPt) + 1] = _mvPt._y;
jPt++;
}
iAs = 1;
nRun = 4.5;
}
function assemble(arrCoo, iRes) {
var snm;
var _mvPt;
var dJ;
var dMax;
(jPt = 0);
(dMax = 0);
while (jPt < qDup) {
snm = getNameSqS(1 + jPt);
_mvK = eval (snm);
_mvK._x = (_mvK._x + arrCoo[jPt * 2]) / 2;
_mvK._y = (_mvK._y + arrCoo[(jPt * 2) + 1]) / 2;
dJ = Math.sqrt(((arrCoo[jPt * 2] - _mvK._x) * (arrCoo[jPt * 2] - _mvK._x)) + ((arrCoo[(jPt * 2) + 1] - _mvK._y) * (arrCoo[(jPt * 2) + 1] - _mvK._y)));
if (dJ > dMax) {
dMax = dJ;
}
jPt++;
}
if (dMax <= 2) {
jPt = 0;
while (jPt < qDup) {
snm = getNameSqS(1 + jPt);
_mvPt = eval (snm);
_mvPt._x = arrCoo[2 * jPt];
_mvPt._y = arrCoo[(2 * jPt) + 1];
jPt++;
}
iRes = 0;
}
return(iRes);
}
var dimSq;
var qDup = 0;
var nRun = 0;
var arrSqDD;
var qParts;
var iBuilt;
var nclKPt;
var arrPD;
var arrBCoo;
var arrCCoo;
var iAs;
Instance of Symbol 15 MovieClip "_mvSqPart" in Symbol 16 MovieClip Frame 1
onClipEvent (mouseDown) {
var iRes;
if (_parent.nRun == 4) {
if (hitTest(_root._xmouse, _root._ymouse, 1)) {
iRes = _parent.testTouchUpper(nDup);
if (!iRes) {
iDrag = 1;
dx = _xmouse;
dy = _ymouse;
}
}
}
}
onClipEvent (mouseUp) {
if (iDrag) {
fillArrCoo(this);
iShine = _parent.defineShine(this);
if (iShine >= 0) {
_parent.placePart(this, iShine);
}
}
iDrag = 0;
}
onClipEvent (mouseMove) {
if (iDrag) {
_x = (_parent._xmouse - dx);
_y = (_parent._ymouse - dy);
}
}
onClipEvent (enterFrame) {
if (iDrag) {
fillArrCoo(this);
iShine = _parent.defineShine(this);
if (iShine >= 0) {
doShine();
} else {
doDull();
}
} else {
doDull();
}
}
Instance of Symbol 8 MovieClip in Symbol 16 MovieClip Frame 1
onClipEvent (load) {
_visible = 0;
_parent._mvSqPart._visible = 0;
}
onClipEvent (enterFrame) {
_parent.timeFlies();
}
Symbol 23 Button
on (release) {
clickB();
}
Symbol 26 MovieClip Frame 1
function clickB() {
_parent.clickB(_txtCaption);
}
Symbol 30 MovieClip Frame 1
function showS() {
iCW = 1;
}
function hideS() {
iCW = 0;
}
function timeFlies() {
if (iCW == 0) {
_visible = 0;
alC = 0;
}
if (iCW == 1) {
_width = wB;
_visible = 1;
if (alC < 96) {
alC = alC + ((100 - alC) / 2);
_alpha = alC;
tC = -1.5707963267949;
} else {
_alpha = 100;
_width = (wB + (25 * (1 + Math.sin(tC))));
if (tC < 4.71238898038469) {
tC = tC + 0.1;
}
}
}
}
var alC = 0;
var iCW = 0;
var wB;
var tC;
Instance of Symbol 8 MovieClip in Symbol 30 MovieClip Frame 1
onClipEvent (load) {
_visible = 0;
_parent._visible = 0;
_parent.wB = _parent._width;
}
onClipEvent (enterFrame) {
_parent.timeFlies();
}