Frame 1
function setFormat(f, s, c, a) {
w_01 = new TextFormat();
w_01.color = c;
w_01.size = s;
w_01.font = f;
if (a != null) {
w_01.align = a;
}
return(w_01);
}
function getLevel(pobj) {
if (pobj.level == null) {
pobj.level = 0;
} else {
pobj.level++;
}
return(pobj.level);
}
function fillBox(pobj, w, h, color) {
with (pobj) {
beginFill(color);
moveTo(0, 0);
lineTo(w, 0);
lineTo(w, h);
lineTo(0, h);
lineTo(0, 0);
endFill();
}
}
function drawBox(pobj, w, h, color) {
with (pobj) {
lineStyle(0, color);
moveTo(0, 0);
lineTo(w - 1, 0);
lineTo(w - 1, h - 1);
lineTo(0, h - 1);
lineTo(0, 0);
}
}
function drawLine(pobj, x1, y1, x2, y2, color) {
with (pobj) {
lineStyle(0, color);
moveTo(x1, y1);
lineTo(x2, y2);
}
}
function fillBoxXY(pobj, x1, y1, x2, y2, color) {
with (pobj) {
lineStyle(0, color);
beginFill(color);
moveTo(x1, y1);
lineTo(x1, y2);
lineTo(x2, y2);
lineTo(x2, y1);
lineTo(x1, y1);
endFill();
}
}
function addPanel(obj, n, x, y, w, h, bgr, border, title, close) {
lev = getLevel(obj);
obj.createEmptyMovieClip(n, lev);
obj[n]._x = x;
obj[n]._y = y;
obj[n].resize = false;
fillBox(obj[n], w, h, bgr);
if (border != null) {
drawBox(obj[n], w, h, border);
}
if (close != null) {
xp = 14;
} else {
xp = 0;
}
if (title != null) {
fillBoxXY(obj[n], 1, 1, obj[n]._width - 1, pan_titHeight, border);
addText(obj[n], n + "tit", title, 2, 2, pan_titfont, (obj[n]._width - 2) - xp, pan_titHeight - 2);
}
if (close != null) {
lp = (pan_titHeight - 14) / 2;
lev = getLevel(obj[n]);
obj[n].attachMovie("ButtonCloseWindow", "close", lev);
lev = 2;
obj[n].close._x = ((obj[n]._width - 14) - lp) - 1;
obj[n].close._y = lp;
obj[n].tabEnabled = false;
obj[n].close.onPress = function () {
this._parent._visible = false;
};
}
}
function addText(obj, n, txt, x, y, f, w, h) {
if (f == null) {
f = main_font;
}
if (w == null) {
ttp = f.getTextExtent((" " + txt) + " ");
h = (ttp.height * txt_vFactor) + 2;
w = ttp.width * txt_hFactor;
}
if (obj.resize != null) {
if ((x + w) > obj._width) {
if (x > obj._width) {
return(undefined);
}
w = obj._width - x;
}
if ((y + h) > obj._height) {
if (y > obj._height) {
return(undefined);
}
h = obj._height - y;
}
}
lev = getLevel(obj);
obj.createTextField(n, lev, x, y, w, h);
obj[n].selectable = false;
obj[n].multiline = true;
obj[n].wordWrap = true;
obj[n].text = txt;
obj[n].setTextFormat(f);
obj[n].setNewTextFormat(f);
}
function addHotLabel(obj, bn, x, y, lobj, lsym, action, txt, action2, f, w) {
lev = getLevel(obj);
obj.createEmptyMovieClip(bn, lev);
obj[bn].level = 0;
obj[bn]._x = x;
obj[bn]._y = y;
obj[bn].action = action;
if (action2 == null) {
action2 = action;
}
obj[bn].action2 = action2;
obj[bn].nobject = lobj;
xd = 4;
if (txt != "") {
w = (w - xd) - 4;
ttp = f.getTextExtent(txt);
ht = (ttp.height * txt_vFactor) + 2;
wt = ttp.width * txt_hFactor;
if (wt > w) {
h = ht * 2;
} else {
h = ht;
}
yd = Math.floor(h / 2);
obj[bn].createEmptyMovieClip("label", obj[bn].level);
fillField(obj[bn].label, 1, 1);
obj[bn].label._x = xd;
obj[bn].label._y = (-yd) + 4;
obj[bn].label.tabEnabled = false;
obj[bn].label.onPress = function () {
this._parent.action2(this._parent.nobject);
};
addText(obj[bn].label, "t", txt, 0, 0, f, w, h);
}
}
function burl() {
getURL ("http://www.ztor.com", "_blank");
}
function getDistance(x1, y1, x2, y2) {
azx = x1 - x2;
azy = y1 - y2;
return((azx * azx) + (azy * azy));
}
function getNearest() {
if (_root["fig" + cur_fig]._x <= ww_xmin) {
return(undefined);
}
if (aadjust_f) {
minDist = shift_mod;
optr1 = -1;
optr2 = -1;
ofig = -1;
_root["fig" + cur_fig].getBasis();
iz = 1;
while (iz < max_tans) {
if ((iz != cur_fig) && (_root["fig" + iz]._x > ww_xmin)) {
xdist = Math.sqrt(getDistance(_root["fig" + cur_fig]._x, _root["fig" + cur_fig]._y, _root["fig" + iz]._x, _root["fig" + iz]._y));
xdrad = _root["fig" + cur_fig].radF + _root["fig" + iz].radF;
if (((xdrad - xdist) < shift_ovr) && (xdist < (xdrad * 4))) {
_root["fig" + iz].getBasis();
iz2 = 0;
while (iz2 < _root["fig" + cur_fig].totcnt) {
iz3 = 0;
while (iz3 < _root["fig" + iz].totcnt) {
dist = getDistance(_root["fig" + cur_fig].midX[iz2], _root["fig" + cur_fig].midY[iz2], _root["fig" + iz].midX[iz3], _root["fig" + iz].midY[iz3]);
if (dist < minDist) {
minDist = dist;
optr1 = iz2;
optr2 = iz3;
ofig = iz;
}
iz3++;
}
iz2++;
}
}
}
iz++;
}
if (ofig != -1) {
deltax = _root["fig" + ofig].midX[optr2] - _root["fig" + cur_fig].midX[optr1];
deltay = _root["fig" + ofig].midY[optr2] - _root["fig" + cur_fig].midY[optr1];
_root["fig" + cur_fig]._x = _root["fig" + cur_fig]._x + deltax;
_root["fig" + cur_fig]._y = _root["fig" + cur_fig]._y + deltay;
gsplay("_sshift");
} else {
gsplay("_sdrop");
}
} else {
gsplay("_sdrop");
}
testGoal();
}
function getRotation() {
cur_rot = _root["fig" + cur_fig]._rotation;
nrot = cur_rot % 45;
_root["fig" + cur_fig]._rotation = (cur_rot - nrot) - 45;
}
function trig(m, ang) {
if (m == 0) {
return(Math.sin(ang * toRadian));
}
return(Math.cos(ang * toRadian));
}
function addFigure(obj, fnum, t, xp, x, y, mode) {
bn = "fig" + fnum;
lev = getLevel(obj);
obj.createEmptyMovieClip(bn, lev);
if (mode == null) {
mode = 0;
}
obj[bn].mode = mode;
obj[bn].model = 1;
obj[bn].tabEnabled = false;
obj[bn].radF = 0;
obj[bn].rad = 0;
obj[bn].radr = 0;
obj[bn].radrS = 0;
obj[bn].type = t;
obj[bn].xp = xp;
obj[bn].xpd2 = xp / 2;
obj[bn].pmirror = 0;
obj[bn].midX = [0, 0, 0, 0, 0, 0, 0, 0];
obj[bn].midY = [0, 0, 0, 0, 0, 0, 0, 0];
obj[bn].midA = null;
obj[bn].xrmed = 0;
obj[bn].xrang = 0;
obj[bn].totcnt = 8;
obj[bn].xdiag1 = 0;
obj[bn].xdiag2 = 0;
obj[bn].drawFigure = function (dcol, mode) {
if (mode != null) {
this.clear();
} else {
switch (this.type) {
case 0 :
zp = this.xp;
this.midA = [90, 0, 90, 0];
this.radr = zp;
this.radF = this.xp;
this.rad = (zp - 3) * (zp - 3);
break;
case 1 :
zp = this.xp / (1 + Math.SQRT2);
this.radr = zp;
this.midA = [45, 0, 90];
this.radrS = this.radr * Math.SQRT2;
this.xrmed = Math.sqrt(((this.xp * this.xpd2) - ((this.xp * this.radr) * Math.SQRT2)) + ((2 * this.radr) * this.radr));
this.xrbis = Math.sqrt((((this.xp * this.xp) * 2) - (((this.xp * this.radr) * 4) / Math.SQRT2)) + ((2 * this.radr) * this.radr));
this.xrang = 90 - ((Math.acos(this.radr / this.xrmed) * 180) / Math.PI);
this.totcnt = 6;
this.radF = zp;
this.rad = this.radrS * this.radrS;
break;
case 2 :
zp = this.xp / 4;
this.midA = [45, 0, 45, 0];
this.radr = zp;
this.radF = zp;
this.xdiag1 = Math.round(this.xp * Math.sqrt(5 / 8));
this.xdiag2 = Math.round(this.xpd2 / Math.SQRT2);
this.rad = this.xdiag2 * this.xdiag2;
}
}
xp = this.xp;
with (this) {
lineStyle(0, _zzcol);
beginFill(dcol);
switch (this.type) {
case 0 :
moveTo(-xp, -xp);
lineTo(xp, -xp);
lineTo(xp, xp);
lineTo(-xp, xp);
lineTo(-xp, -xp);
break;
case 1 :
zp = this.radr;
zp2 = (xp * Math.SQRT2) - zp;
moveTo(-zp, zp);
lineTo(zp2, zp);
lineTo(-zp, -zp2);
lineTo(-zp, zp);
break;
case 2 :
zp = xp / 4;
zp2 = (xp * 3) / 4;
if (this.pmirror == 1) {
moveTo(-zp2, zp);
lineTo(zp, zp);
lineTo(zp2, -zp);
lineTo(-zp, -zp);
lineTo(-zp2, zp);
} else {
moveTo(-zp, zp);
lineTo(zp2, zp);
lineTo(zp, -zp);
lineTo(-zp2, -zp);
lineTo(-zp, zp);
}
}
endFill();
}
};
obj[bn].onPress = function () {
if (act_help) {
return(undefined);
}
if (this.model == 0) {
return(undefined);
}
hide_tit();
dlevel++;
this.swapDepths(dlevel);
if (cur_fig != "") {
_root["fig" + cur_fig].drawFigure(_zcol, true);
}
cur_fig = this.num;
_root["fig" + cur_fig].drawFigure(clr_g, true);
radius = (this._xmouse * this._xmouse) + (this._ymouse * this._ymouse);
if ((radius > this.rad) && (arotate_f == 1)) {
this.rotating = true;
this.oldangle = Math.atan2(this._ymouse, this._xmouse);
} else {
this.moving = true;
this.startDrag(false, wd_xmin, ww_ymin, ww_xmax, ww_ymax);
}
};
obj[bn].onMouseMove = function () {
if (act_help) {
return(undefined);
}
if (this.model == 0) {
return(undefined);
}
if (this.rotating && (!this.rotactive)) {
this.rotactive = true;
this._rotation = this._rotation + ((180 * (Math.atan2(this._ymouse, this._xmouse) - this.oldangle)) / Math.PI);
this.oldangle = Math.atan2(this._ymouse, this._xmouse);
this.rotactive = false;
}
};
obj[bn].onRelease = function () {
if (this.model == 0) {
return(undefined);
}
if (this.moving) {
this.stopDrag();
} else {
this._rotation = Math.round(this._rotation / 22.5) * 22.5;
}
this.moving = false;
this.rotating = false;
getNearest();
};
obj[bn].onReleaseOutside = obj[bn].onRelease;
obj[bn].onEnterFrame = function () {
if (act_help) {
return(undefined);
}
if (this.model == 0) {
return(undefined);
}
if (cur_fig == this.num) {
if (this.keywaiting) {
if (!Key.isDown(this.keyvalue)) {
this.keywaiting = false;
}
} else {
if (Key.isDown(17)) {
this.keywaiting = true;
this.keyvalue = 17;
this.mirror(clr_g);
getNearest();
}
if (Key.isDown(9)) {
this.keywaiting = true;
this.keyvalue = 9;
getRotation();
getNearest();
}
}
}
};
obj[bn].mirror = function (xcol) {
if (this.type == 2) {
this.pmirror = 1 - this.pmirror;
if (this.pmirror == 0) {
this.midA = [45, 0, 45, 0];
} else {
this.midA = [135, 0, 135, 0];
}
this.drawFigure(xcol, true);
}
if (this.type == 1) {
this._rotation = this._rotation + 180;
this.drawFigure(xcol, true);
}
};
obj[bn].getBasis = function () {
if (this.type == 0) {
xx = this.xp * Math.SQRT2;
kk = 0;
indptr = 0;
while (indptr < 4) {
xx1 = this._rotation + (90 * indptr);
this.midX[kk] = (xx * trig(1, xx1 - 45)) + this._x;
this.midY[kk] = (xx * trig(0, xx1 - 45)) + this._y;
kk++;
this.midX[kk] = (this.xp * trig(1, xx1)) + this._x;
this.midY[kk] = (this.xp * trig(0, xx1)) + this._y;
kk++;
indptr++;
}
}
if (this.type == 1) {
this.midX[0] = (this.xrbis * trig(1, this._rotation + 22.5)) + this._x;
this.midY[0] = (this.xrbis * trig(0, this._rotation + 22.5)) + this._y;
this.midX[1] = (this.radr * trig(1, this._rotation - 45)) + this._x;
this.midY[1] = (this.radr * trig(0, this._rotation - 45)) + this._y;
this.midX[2] = (this.xrbis * trig(1, this._rotation - 112.5)) + this._x;
this.midY[2] = (this.xrbis * trig(0, this._rotation - 112.5)) + this._y;
this.midX[3] = (this.xrmed * trig(1, this._rotation + this.xrang)) + this._x;
this.midY[3] = (this.xrmed * trig(0, this._rotation + this.xrang)) + this._y;
this.midX[4] = (this.radrS * trig(1, this._rotation + 135)) + this._x;
this.midY[4] = (this.radrS * trig(0, this._rotation + 135)) + this._y;
this.midX[5] = (this.xrmed * trig(1, this._rotation - (90 + this.xrang))) + this._x;
this.midY[5] = (this.xrmed * trig(0, this._rotation - (90 + this.xrang))) + this._y;
}
if (this.type == 2) {
if (this.pmirror == 0) {
alfa1 = this._rotation - 45;
alfa2 = this._rotation + 18.43;
alfa3 = this._rotation + 45;
alfa4 = 135;
xdiag = this.xdiag1;
xdiag0 = this.xdiag2;
} else {
alfa1 = this._rotation - 18.43;
alfa2 = this._rotation + 45;
alfa3 = this._rotation + 135;
alfa4 = 161.57;
xdiag0 = this.xdiag1;
xdiag = this.xdiag2;
}
this.midX[0] = (xdiag0 * trig(1, alfa1)) + this._x;
this.midY[0] = (xdiag0 * trig(0, alfa1)) + this._y;
this.midX[1] = (this.xpd2 * trig(1, this._rotation)) + this._x;
this.midY[1] = (this.xpd2 * trig(0, this._rotation)) + this._y;
this.midX[2] = (xdiag * trig(1, alfa2)) + this._x;
this.midY[2] = (xdiag * trig(0, alfa2)) + this._y;
this.midX[3] = ((this.xpd2 / Math.SQRT2) * trig(1, alfa3)) + this._x;
this.midY[3] = ((this.xpd2 / Math.SQRT2) * trig(0, alfa3)) + this._y;
this.midX[4] = (xdiag0 * trig(1, this._rotation + alfa4)) + this._x;
this.midY[4] = (xdiag0 * trig(0, this._rotation + alfa4)) + this._y;
this.midX[5] = (this.xpd2 * trig(1, this._rotation + 180)) + this._x;
this.midY[5] = (this.xpd2 * trig(0, this._rotation + 180)) + this._y;
this.midX[6] = (xdiag * trig(1, alfa2 + 180)) + this._x;
this.midY[6] = (xdiag * trig(0, alfa2 + 180)) + this._y;
this.midX[7] = ((this.xpd2 / Math.SQRT2) * trig(1, alfa3 + 180)) + this._x;
this.midY[7] = ((this.xpd2 / Math.SQRT2) * trig(0, alfa3 + 180)) + this._y;
}
};
obj[bn].drawFigure(_zcol);
obj[bn]._x = x;
obj[bn]._y = y;
obj[bn].num = fnum;
obj[bn].moving = false;
obj[bn].rotating = false;
obj[bn].oldangle = false;
obj[bn].rotactive = false;
obj[bn].keywaiting = false;
obj[bn].keyvalue = 0;
}
function draw_figure(pobj, fcol, lcol, factor, tan_array, xa, ya) {
_zcol = fcol;
_zzcol = lcol;
find7 = 1;
ind7 = 0;
while (ind7 < (max_tans - 1)) {
xind7 = tan_array[ind7 * 3];
if (xind7 != -1) {
tind7 = 1;
if (find7 == 6) {
tind7 = 0;
}
if (find7 == 7) {
tind7 = 2;
}
zdrunit = drunit;
switch (find7) {
case 3 :
case 4 :
zdrunit = drunit / 2;
break;
case 5 :
zdrunit = (drunit * Math.SQRT2) / 2;
break;
case 6 :
zdrunit = (drunit * Math.SQRT2) / 4;
}
addFigure(pobj, "" + find7, tind7, zdrunit * factor, 16711680, 0, 0);
pobj["fig" + find7]._x = (tan_array[ind7 * 3] * factor) + xa;
pobj["fig" + find7]._y = (tan_array[(ind7 * 3) + 1] * factor) + ya;
pobj["fig" + find7]._rotation = tan_array[(ind7 * 3) + 2];
pobj["fig" + find7].model = 0;
}
find7++;
ind7++;
}
if (tan_array[21] != 0) {
pobj.fig7.pmirror = 1;
pobj.fig7.drawFigure(_zcol, true);
}
_zcol = clr_l;
_zzcol = clr_b;
}
function initpos() {
hide_tit();
fxpos = mid_xpos - 2;
fypos = starty + 2;
_root.fig1._x = (fxpos + drunit) * delta;
_root.fig1._y = (fypos + frad) * delta;
_root.fig1._rotation = -45;
_root.fig1.drawFigure(_zcol, true);
_root.fig1.model = 1;
_root.fig2._x = (((fxpos + (drunit * 2)) - frad) * delta) - 1;
_root.fig2._y = ((fypos + drunit) * delta) - 1;
_root.fig2._rotation = 45;
_root.fig2.drawFigure(_zcol, true);
_root.fig2.model = 1;
_root.fig3._x = (fxpos + (frad / 2)) * delta;
_root.fig3._y = (fypos + (drunit / 2)) * delta;
_root.fig3._rotation = -135;
_root.fig3.drawFigure(_zcol, true);
_root.fig3.model = 1;
_root.fig4._x = (fxpos + drunit) * delta;
_root.fig4._y = (((fypos + drunit) + (drunit / 2)) - (frad / 2)) * delta;
_root.fig4._rotation = 135;
_root.fig4.drawFigure(_zcol, true);
_root.fig4.model = 1;
_root.fig5._x = (fxpos + (drunit / 3.41421356237309)) * delta;
_root.fig5._y = ((fypos + (drunit * 2)) - (drunit / 3.41421356237309)) * delta;
_root.fig5._rotation = 0;
_root.fig5.drawFigure(_zcol, true);
_root.fig5.model = 1;
_root.fig6._x = (fxpos + (drunit / 2)) * delta;
_root.fig6._y = (fypos + drunit) * delta;
_root.fig6._rotation = -45;
_root.fig6.drawFigure(_zcol, true);
_root.fig6.model = 1;
_root.fig7._x = ((fxpos + drunit) + (drunit / 4)) * delta;
_root.fig7._y = ((fypos + (drunit * 2)) - (drunit / 4)) * delta;
_root.fig7._rotation = 0;
_root.fig7.pmirror = 0;
_root.fig7.drawFigure(_zcol, true);
_root.fig7.model = 1;
}
function bb_help() {
gsplay("_sbutton");
act_help = true;
_root.level = dlevel;
warn_modalBgr = 13421772 /* 0xCCCCCC */;
addPanel(_root, "_modalbgr", 0, 0, Stage.width, Stage.height, warn_modalBgr);
_modalbgr._alpha = 50;
_modalbgr.useHandCursor = false;
_modalbgr.onRollOver = function () {
};
_modalbgr.tabEnabled = false;
dlevel++;
_root.help.swapDepths(dlevel);
_root.help._visible = true;
_root.help.cord.text = "";
ind1 = 1;
while (ind1 < max_tans) {
if (_root["fig" + ind1]._x > ww_xmin) {
aa1 = ((((("" + ((Math.round(_root["fig" + ind1]._x * 100) / 100) - ww_xmin)) + ",") + ((Math.round(_root["fig" + ind1]._y * 100) / 100) - ww_ymin)) + ",") + (Math.round(_root["fig" + ind1]._rotation * 100) / 100)) + ", ";
} else {
aa1 = "-1,-1,-1, ";
}
_root.help.cord.text = _root.help.cord.text + aa1;
ind1++;
}
_root.help.cord.text = _root.help.cord.text + _root.fig7.pmirror;
}
function bb_restart() {
gsplay("_sbutton");
if (cur_fig != "") {
_root["fig" + cur_fig].drawFigure(_zcol, true);
cur_fig = "";
}
initpos();
}
function gsplay(name) {
_root[old_sound].stop();
if (sound_f) {
_root[name].setVolume(100);
_root[name].start();
}
old_sound = name;
}
function bb_sound() {
sound_f = !sound_f;
_root.bsof._visible = !sound_f;
_root.bson._visible = sound_f;
_root[old_sound].stop();
gsplay("_sbutton");
}
function allshift(mv) {
ind7 = 1;
while (ind7 < max_tans) {
if (_root["fig" + ind7]._x > ww_xmin) {
switch (mv) {
case 0 :
if ((_root["fig" + ind7]._y - 40) <= ww_ymin) {
return(undefined);
}
break;
case 1 :
if ((_root["fig" + ind7]._y + 40) >= ww_ymax) {
return(undefined);
}
break;
case 2 :
if ((_root["fig" + ind7]._x - 40) <= ww_xmin) {
return(undefined);
}
break;
case 3 :
if ((_root["fig" + ind7]._x + 40) < ww_xmax) {
break;
}
return(undefined);
}
}
ind7++;
}
gsplay("_sbutton");
ind7 = 1;
while (ind7 < max_tans) {
if (_root["fig" + ind7]._x > ww_xmin) {
switch (mv) {
case 0 :
_root["fig" + ind7]._y = _root["fig" + ind7]._y - 5;
break;
case 1 :
_root["fig" + ind7]._y = _root["fig" + ind7]._y + 5;
break;
case 2 :
_root["fig" + ind7]._x = _root["fig" + ind7]._x - 5;
break;
case 3 :
_root["fig" + ind7]._x = _root["fig" + ind7]._x + 5;
}
}
ind7++;
}
}
function bb_up() {
allshift(0);
}
function bb_dn() {
allshift(1);
}
function bb_lf() {
allshift(2);
}
function bb_rt() {
allshift(3);
}
function drawLinkFig(nf, arr) {
_root["st" + nf].area.removeMovieClip();
lev = _root["st" + nf].level;
_root["st" + nf].createEmptyMovieClip("area", lev);
draw_figure(_root["st" + nf].area, clr_g, clr_g, min_factor, arr, 0, 0);
}
function show_set() {
gsplay("_sbutton");
if (cur_set == 1) {
_root.bprev._visible = false;
} else {
_root.bprev._visible = true;
}
if (cur_set == max_set) {
_root.bnext._visible = false;
} else {
_root.bnext._visible = true;
}
ind2 = 0;
while (ind2 < 8) {
drawLinkFig("" + ind2, tang_set[((cur_set - 1) * 8) + ind2]);
ind2++;
}
}
function bb_prev() {
cur_set--;
show_set();
}
function bb_next() {
cur_set++;
show_set();
}
function sel_tang(nt) {
gsplay("_snew");
aind = parseInt(nt.charAt(2));
tang_sel = ((cur_set - 1) * 8) + aind;
target_tan = tang_set[tang_sel];
task_def = true;
bt_giveup();
if (cur_fig != "") {
_root["fig" + cur_fig].drawFigure(_zcol, true);
cur_fig = "";
}
initpos();
_root.ct.area.removeMovieClip();
lev = _root.ct.level;
_root.ct.createEmptyMovieClip("area", lev);
draw_figure(_root.ct.area, clr_g, clr_g, mid_factor, target_tan, 0, pan_titHeight);
}
function delDuplicate(xarr1) {
xval = Math.floor(xarr1[0] / 1000);
aiz3 = 1;
while (aiz3 < basic_len) {
xxval = Math.floor(xarr1[aiz3] / 1000);
if ((xxval > xval) && ((xxval - xval) < targ_eps)) {
xarr1[aiz3] = (xval * 1000) + (xarr1[aiz3] % 1000);
} else {
xval = xxval;
}
aiz3++;
}
xarr1.sort();
zret = 0;
aiz3 = 0;
while (aiz3 < basic_len) {
if (xarr1[aiz3] != 999999) {
xval = Math.floor(xarr1[aiz3] / 1000);
yval = xarr1[aiz3] % 1000;
aiz4 = aiz3 + 1;
while (aiz4 < basic_len) {
if (Math.abs((xarr1[aiz4] / 1000) - xval) < targ_eps) {
if (Math.abs((xarr1[aiz4] % 1000) - yval) < targ_eps) {
zret++;
xarr1[aiz4] = 999999 /* 0x0F423F */;
}
} else if (xarr1[aiz4] != 999999) {
break;
}
aiz4++;
}
}
aiz3++;
}
return(zret);
}
function bb_giveup() {
gsplay("_sbutton");
bt_giveup();
}
function bt_giveup() {
if (!task_def) {
return(undefined);
}
if (cur_fig != "") {
_root["fig" + cur_fig].drawFigure(_zcol, true);
cur_fig = "";
}
initpos();
ind7 = 0;
while (ind7 < (max_tans - 1)) {
xind7 = target_tan[ind7 * 3];
if (xind7 != -1) {
_root["fig" + (ind7 + 1)].model = 0;
_root["fig" + (ind7 + 1)]._x = target_tan[ind7 * 3] + ww_xmin;
_root["fig" + (ind7 + 1)]._y = target_tan[(ind7 * 3) + 1] + ww_ymin;
_root["fig" + (ind7 + 1)]._rotation = target_tan[(ind7 * 3) + 2];
}
ind7++;
}
if (target_tan[21] != 0) {
_root.fig7.pmirror = 1;
_root.fig7.drawFigure(_zcol, true);
}
aizi = 0;
targ_miny = 1000;
targ_maxy = 0;
aiz = 1;
while (aiz < max_tans) {
_root["fig" + aiz].getBasis();
aiz2 = 0;
while (aiz2 < _root["fig" + aiz].totcnt) {
newy = Math.round(_root["fig" + aiz].midY[aiz2]);
if (newy < targ_miny) {
targ_miny = newy;
}
if (newy > targ_maxy) {
targ_maxy = newy;
}
zetrezZ[aizi] = (Math.round(_root["fig" + aiz].midX[aiz2]) * 1000) + newy;
aizi++;
aiz2 = aiz2 + 2;
}
aiz++;
}
zetrezZ.sort();
targ_minx = Math.floor(zetrezZ[0] / 1000);
targ_maxx = Math.floor(zetrezZ[basic_len - 1] / 1000);
targ_base = delDuplicate(zetrezZ);
zetrezZ.sort();
}
function bb_arotate() {
gsplay("_sbutton");
arotate_f = !arotate_f;
_root.help.help_p.help_a._visible = arotate_f;
_root.help.help_p.help_d._visible = !arotate_f;
_root.help.help_p.rena._visible = arotate_f;
_root.help.help_p.rdis._visible = !arotate_f;
}
function bb_aadjust() {
gsplay("_sbutton");
aadjust_f = !aadjust_f;
_root.help.help_p.aena._visible = aadjust_f;
_root.help.help_p.adis._visible = !aadjust_f;
}
function testGoal() {
if (!task_def) {
return(undefined);
}
aizi = 0;
test_miny = 1000;
test_maxy = 0;
aiz = 1;
while (aiz < max_tans) {
if (_root["fig" + aiz]._x < ww_xmin) {
return(undefined);
}
_root["fig" + aiz].getBasis();
aiz2 = 0;
while (aiz2 < _root["fig" + aiz].totcnt) {
newy = Math.round(_root["fig" + aiz].midY[aiz2]);
if (newy < test_miny) {
test_miny = newy;
}
if (newy > test_maxy) {
test_maxy = newy;
}
tstrezZ[aizi] = (Math.round(_root["fig" + aiz].midX[aiz2]) * 1000) + newy;
aizi++;
aiz2 = aiz2 + 2;
}
aiz++;
}
dify = test_miny - targ_miny;
if (((test_maxY - targ_maxY) - dify) >= targ_eps) {
return(undefined);
}
tstrezZ.sort();
test_minx = Math.floor(tstrezZ[0] / 1000);
test_maxx = Math.floor(tstrezZ[basic_len - 1] / 1000);
difx = test_minx - targ_minx;
if (((test_maxX - targ_maxX) - difx) >= targ_eps) {
return(undefined);
}
tst_base = delDuplicate(tstrezZ);
if (Math.abs(targ_base - tst_base) > 1) {
return(undefined);
}
tstrezZ.sort();
errors = 0;
aiz5 = 0;
while (aiz5 < basic_len) {
if (zetrezZ[aiz5] == 999999) {
break;
}
if (Math.abs((Math.floor(tstrezZ[aiz5] / 1000) - Math.floor(zetrezZ[aiz5] / 1000)) - difx) > 2) {
errors++;
break;
}
if (Math.abs(((tstrezZ[aiz5] % 1000) - (zetrezZ[aiz5] % 1000)) - dify) > 2) {
errors++;
break;
}
aiz5++;
}
if (errors > 0) {
if (tang_sel < 24) {
return(undefined);
}
iz7 = 1;
while (iz7 < (max_tans - 1)) {
iz7t = iz7 + 1;
while (iz7t < max_tans) {
zxdist = Math.sqrt(getDistance(_root["fig" + iz7]._x, _root["fig" + iz7]._y, _root["fig" + iz7t]._x, _root["fig" + iz7t]._y));
zxdrad = _root["fig" + iz7].radF + _root["fig" + iz7t].radF;
if ((zxdrad - zxdist) > 2) {
return(undefined);
}
iz7t++;
}
iz7++;
}
}
gsplay("_swin");
_zzcol = clr_g;
ind8 = 1;
while (ind8 < max_tans) {
_root["fig" + ind8].model = 0;
dlevel++;
_root["fig" + ind8].swapDepths(dlevel);
_root["fig" + ind8].drawFigure(_zzcol, true);
ind8++;
}
_zzcol = clr_b;
_root.ptit._visible = true;
_root.ptit._alpha = 40;
task_def = false;
}
function hide_tit() {
if (_root.ptit._visible) {
_root.ptit._visible = false;
}
}
clr_b = 6697728 /* 0x663300 */;
clr_g = 10053171 /* 0x996633 */;
clr_l = 13408614 /* 0xCC9966 */;
clr_w = 16572869 /* 0xFCE1C5 */;
_zcol = clr_l;
_zzcol = clr_b;
max_tans = 8;
dlevel = 0;
cur_fig = "";
task_def = false;
sound_f = false;
old_sound = "";
drunit = 85;
act_help = false;
shift_mod = 400;
shift_ovr = 10;
toRadian = (Math.PI/180);
frad = Math.round(drunit / 2.41421356237309);
delta = 1.07;
max_len = 400;
mid_len = 200;
min_len = 60;
fname = "Arial";
fsize = 14;
startx = 10;
starty = 80;
sdelim = 25;
main_fontName = fname;
main_fontSize = fsize;
main_fontColor = clr_b;
pan_titfontColor = clr_b;
txt_vFactor = 1.4;
txt_hFactor = 1.3;
txt_wsymbol = "W";
pan_titHeight = 20;
main_font = setFormat(main_fontName, main_fontSize, main_fontColor);
pan_titfont = setFormat(main_fontName, main_fontSize, main_fontColor, "center");
pan_titfont.bold = true;
url_font = setFormat(fname, 10, clr_b, "right");
url_font.underline = true;
nxpos = startx;
nypos = starty;
nypos = 195;
bb_sound();
addText(this, "sel_task", "SELECT PUZZLE", nxpos, nypos, pan_titfont, b_restart._width, 40);
nypos = nypos + (sel_task._heigh + sdelim);
ind1 = 0;
while (ind1 < 4) {
ind2 = 0;
while (ind2 < 2) {
addPanel(_root, "st" + ((ind1 * 2) + ind2), nxpos + ((min_len + 5) * ind2), nypos, min_len, min_len, clr_w, clr_g);
_root["st" + ((ind1 * 2) + ind2)].onPress = function () {
sel_tang(this._name);
};
_root["st" + ((ind1 * 2) + ind2)].tabEnabled = false;
lev = getLevel(_root["st" + ((ind1 * 2) + ind2)]);
_root["st" + ((ind1 * 2) + ind2)].createEmptyMovieClip("area", lev);
ind2++;
}
nypos = nypos + (min_len + 5);
ind1++;
}
mid_xpos = 151;
addFigure(_root, "1", 1, drunit, 0, 0);
addFigure(_root, "2", 1, drunit, 0, 0);
addFigure(_root, "3", 1, drunit / 2, 0, 0);
addFigure(_root, "4", 1, drunit / 2, 0, 0);
addFigure(_root, "5", 1, (drunit * Math.SQRT2) / 2, 0, 0);
addFigure(_root, "6", 0, (drunit * Math.SQRT2) / 4, 0, 0);
addFigure(_root, "7", 2, drunit, 0, 0);
initpos();
fillBoxXY(_root, mid_xpos, starty, mid_xpos + mid_len, starty + mid_len, clr_w);
addPanel(_root, "ct", mid_xpos, (starty + mid_len) + 5, mid_len, mid_len + pan_titHeight, clr_l, clr_l, "CURRENT PUZZLE");
lev = getLevel(_root.ct);
_root.ct.createEmptyMovieClip("area", lev);
_root.ct.useHandCursor = false;
_root.ct.tabEnabled = false;
_root.ct.onPress = function () {
};
nypos = starty;
addText(this, "sh_text", "SHIFT ALL TANS TO THE", (mid_xpos + mid_len) + (sdelim * 3), nypos - 2, pan_titfont);
fillBoxXY(_root, (mid_xpos + mid_len) + sdelim, starty + 20, ((mid_xpos + mid_len) + sdelim) + max_len, (starty + max_len) + 20, clr_w);
_root.bl.tabEnabled = false;
_root.br.tabEnabled = false;
_root.bu.tabEnabled = false;
_root.bd.tabEnabled = false;
_root.brestart.tabEnabled = false;
_root.bgiveup.tabEnabled = false;
_root.bson.tabEnabled = false;
_root.bsof.tabEnabled = false;
_root.bhelp.tabEnabled = false;
_root.bpref.tabEnabled = false;
_root.bnext.tabEnabled = false;
wd_xmin = mid_xpos + sdelim;
ww_xmin = (mid_xpos + mid_len) + sdelim;
ww_xmax = ((mid_xpos + mid_len) + sdelim) + max_len;
ww_ymin = starty + 20;
ww_ymax = (starty + max_len) + 20;
lev = getLevel(this);
attachMovie("tpagoda", "ptit", lev);
_root.ptit.tabEnabled = false;
_root.ptit._x = ww_xmin;
_root.ptit._y = ww_ymin;
addHotLabel(this, "azurl", 535, 30, null, "", null, "Copyright Andrey D.Orlov WWW.ZTOR.COM", burl, url_font, 200);
addPanel(_root, "help", 110, 30, 610, 450, clr_w, clr_l, "HELP & SETTINGS", true);
_root.help.tabEnabled = false;
_root.help.attachMovie("help_p", "help_p", 2);
_root.help.help_p._x = 2;
_root.help.help_p._y = pan_titHeight + 2;
_root.help.help_p.help_a._visible = false;
_root.help.help_p.help_d._visible = true;
_root.help.level = 2;
_root.help.close.onPress = function () {
_root.help._visible = false;
_modalbgr.removeMovieClip();
act_help = false;
};
arotate_f = false;
bb_arotate();
aadjust_f = false;
bb_aadjust();
addText(_root.help, "t_cord", "Current coordinates: ", 10, _root.help._height - 65, main_font);
addText(_root.help, "cord", "", 10, _root.help._height - 45, main_font, 590, 50);
_root.help.cord.selectable = true;
_root.help._visible = false;
min_factor = min_len / max_len;
mid_factor = mid_len / max_len;
dlevel = _root.level;
basic_len = 23;
tang_sel = 0;
targ_minx = 0;
targ_miny = 0;
targ_maxx = 0;
targ_maxy = 0;
targ_base = 0;
targ_eps = 4;
zetrezZ = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
tstrezZ = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
tempX = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
tempY = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
target_tan = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0];
tang_set = array();
tang_set.push([257.7, 258.5, 135, 172.1, 243.65, -45, 154.45, 335.9, -90, 300.2, 311.3, -180, 147.1, 64.25, 135, 177.15, 119.15, -90, 147.25, 179.15, -45, 0]);
tang_set.push([186.35, 156.35, 135, 271.35, 141.75, -45, 143.85, 209.15, -180, 80.1, 195.25, 135, 246.1, 251.25, -135, 191.15, 221.15, -90, 285.1, 212.25, 0, 0]);
tang_set.push([149.1, 190, 135, 234.1, 175.4, -45, 136.25, 358.15, 0, 131.1, 303.25, 180, 259.1, 55.25, 135, 289.1, 110.25, 0, 149.1, 255.25, -45, 0]);
tang_set.push([168.2, 189.35, 90, 302.55, 118.55, 135, 154.2, 277.95, 135, 175.05, 136.2, 135, 107.7, 213.95, -90, 217.55, 111.3, -45, 72.65, 268.8, -45, 0]);
tang_set.push([201.25, 103.75, 45, 91.65, 283.9, 90, 159.05, 206.2, -180, 254.8, 231.35, 0, 332.5, 248.95, 45, 206.75, 218.65, -90, 116.75, 158.6, 45, 1]);
tang_set.push([269.65, 223.95, -45, 184.65, 238.55, 135, 74.75, 188.8, 90, 282.05, 286.2, -90, 207.25, 116.15, 135, 98.95, 231.75, -45, 117.1, 141.05, -45, 0]);
tang_set.push([176.05, 249.25, 45, 246.5, 249.25, 0, 271.6, 163.65, -135, 169.05, 181.2, -45, 126.5, 78.55, 135, 156.6, 133.5, -90, 232.8, 142.4, 90, 1]);
tang_set.push([202.8, 210.95, 45, 273.25, 211.05, -135, 68.05, 186.25, -135, 323.05, 186.2, -45, 153.05, 246.2, 135, 92.95, 143.75, -45, 114.15, 207.55, 90, 0]);
tang_set.push([148.05, 214.25, 0, 198.05, 334.2, -90, 109.3, 65.25, -135, 159.05, 65.25, 45, 173.2, 274.1, -45, 134.1, 108, -45, 293.15, 339.4, -45, 0]);
tang_set.push([292.05, 226.2, -157, 161.5, 226.2, 68, 48.25, 164.2, -135, 98.05, 164.2, 45, 227, 225.65, -112, 73.15, 206.7, -45, 359.35, 143.95, -90, 0]);
tang_set.push([125.6, 202.2, 45, 196.05, 202.2, 90, 323.05, 149.2, 135, 262.95, 209.35, -90, 118.3, 279.9, 135, 75.8, 244.7, -45, 220.8, 257.25, -45, 0]);
tang_set.push([236.1, 283.2, 135, 151.1, 268.65, -45, 101.2, 113.25, -135, 143.65, 215.75, 0, 296.2, 258.3, -45, 96, 203.3, -90, 126.05, 143.25, -45, 0]);
tang_set.push([279.6, 219.6, -90, 229.85, 169.85, 90, 177.3, 177.55, -90, 74.1, 219.15, 135, 339.7, 194.7, -135, 164.9, 225.25, -90, 104.1, 194.25, 45, 0]);
tang_set.push([148.3, 237.4, 90, 233.35, 251.75, 135, 95.45, 244.65, -90, 275.95, 184.4, -90, 113, 117.15, 135, 143.1, 172.1, 90, 297.05, 223.2, 0, 0]);
tang_set.push([141.75, 215, 90, 261.95, 215, 90, 341.95, 148.95, 45, 304.65, 161.4, 0, 201.85, 239.85, -90, 346.95, 222.25, -45, 77, 149, -135, 1]);
tang_set.push([211.05, 297.85, 0, 260.8, 248.1, -45, 133.35, 230.5, -135, 141.2, 103.9, -90, 150.95, 273, 45, 159, 188, -45, 180.25, 124.25, 90, 1]);
tang_set.push([110.95, 231.95, 0, 220.8, 242.25, -180, 58.15, 189.45, -90, 123.35, 284.75, 90, 195.95, 182.15, -90, 199.55, 100.75, -45, 319.55, 228.2, 0, 0]);
tang_set.push([202, 149.95, 135, 287, 220.35, -45, 117, 160.25, -45, 311.8, 355.05, -90, 56.85, 117.75, 0, 180.75, 78.95, -45, 308.2, 291.35, -90, 0]);
tang_set.push([163.7, 199.85, 0, 213.75, 150.2, -180, 128.55, 320.4, 45, 231.15, 345.05, 135, 171.05, 260.3, 90, 189.1, 73.25, -45, 209.85, 299.1, -90, 0]);
tang_set.push([189.4, 177.7, -45, 239.2, 227.5, 45, 146.9, 209.85, 0, 231.9, 124.85, 135, 214.25, 347.45, 135, 210.65, 78.7, -45, 244.4, 312.45, -135, 0]);
tang_set.push([164.15, 144.5, 45, 175.1, 254.7, 0, 259.25, 169, 0, 216.85, 186.75, 0, 139.1, 84.85, 90, 199.95, 319.95, 0, 220.5, 123.05, 90, 1]);
tang_set.push([193.3, 268.5, 0, 243.05, 218.7, 45, 73, 286.1, -45, 295.9, 261.2, -135, 133.15, 243.6, -90, 257, 112.45, -45, 299.4, 197.25, 90, 1]);
tang_set.push([259.8, 242.05, -90, 210.15, 192.6, 90, 97.05, 139.4, -90, 157.3, 174.95, 180, 319.9, 217.15, -135, 144.75, 127, 0, 144.8, 217.3, 45, 0]);
tang_set.push([202.85, 212.05, -45, 117.85, 141.55, 135, 245.35, 159.15, 135, 181.6, 265.45, 135, 287.85, 212.05, 135, 202.85, 134.3, -45, 291.3, 258.1, 0, 0]);
tang_set.push([175.85, 111.65, -135, 175.85, 281.65, -135, 243.2, 154, -135, 225.55, 256.6, -45, 200.65, 171.7, -90, 268.05, 196.5, -45, 204.3, 217.8, 0, 0]);
tang_set.push([205.8, 198.15, 135, 205.8, 268.6, -45, 248.25, 130.7, 135, 180.9, 148.35, -135, 265.95, 173.3, -180, 205.75, 105.85, -45, 142.05, 169.6, -90, 0]);
tang_set.push([154.3, 242.15, -135, 253.85, 242.15, 45, 221.65, 114.6, -135, 204.25, 217.25, -45, 179.45, 132.3, -90, 246.5, 157.1, -45, 182.95, 178.4, 0, 0]);
tang_set.push([141, 122.75, -45, 275.8, 257.65, 45, 183.5, 154.95, 135, 286.1, 172.65, -135, 286.1, 112.45, -180, 225.75, 130.35, -45, 247.1, 193.95, -90, 0]);
tang_set.push([296.2, 194.65, -135, 105.8, 194.65, 45, 183.45, 152.05, 180, 243.4, 237.15, -90, 165.95, 194.65, -135, 231.15, 164.5, -90, 201.1, 224.65, -45, 0]);
tang_set.push([194.3, 134.1, -45, 236.75, 261.55, -45, 279.35, 208.7, 135, 127, 141.25, -135, 176.65, 201.45, 0, 236.85, 183.85, -45, 130.65, 205, 90, 0]);
tang_set.push([202.2, 133.85, -45, 262.25, 194, 45, 254.95, 261.35, 0, 159.7, 261.45, -90, 142.05, 218.75, -135, 207.25, 248.9, -90, 147.2, 158.6, 45, 0]);
tang_set.push([138, 213.65, -45, 223, 228.25, 135, 281.9, 176.9, -135, 95.5, 160.8, 135, 239.4, 159.3, 180, 306.75, 219.4, -45, 158.2, 155.7, 0, 0]);
cur_set = 1;
max_set = 4;
show_set();
_sinit = new Sound();
_sinit.attachSound("_sinit");
_snew = new Sound();
_snew.attachSound("_snew");
_swin = new Sound();
_swin.attachSound("_swin");
_sdrop = new Sound();
_sdrop.attachSound("_sdrop");
_sshift = new Sound();
_sshift.attachSound("_sshift");
_sbutton = new Sound();
_sbutton.attachSound("_sbutton");
gsplay("_sinit");
stop();
Symbol 54 Button
on (release) {
_root.bb_aadjust();
}
Symbol 55 Button
on (release) {
_root.bb_arotate();
}
Symbol 59 Button
on (release) {
_root.bb_aadjust();
}
Symbol 60 Button
on (release) {
_root.bb_arotate();
}
Symbol 71 Button
on (release) {
_root.bb_lf();
}
Symbol 72 Button
on (release) {
_root.bb_rt();
}
Symbol 73 Button
on (release) {
_root.bb_up();
}
Symbol 74 Button
on (release) {
_root.bb_dn();
}
Symbol 78 Button
on (release) {
_root.bb_restart();
}
Symbol 80 Button
on (release) {
_root.bb_giveup();
}
Symbol 82 Button
on (release) {
_root.bb_sound();
}
Symbol 84 Button
on (release) {
_root.bb_sound();
}
Symbol 87 Button
on (release) {
_root.bb_help();
}
Symbol 92 Button
on (release) {
_root.bb_prev();
}
Symbol 94 Button
on (release) {
_root.bb_next();
}