Frame 1
stop();
Frame 2
initXML = "<item n=\"_pc1\" m=\"_pc1_mus\" />";
XML.prototype.onData = function (src) {
if (((src == "") || (src == null)) || (src == undefined)) {
_root.gotoAndStop("lerr");
return(undefined);
}
this.parseXML(src);
this.loaded = true;
};
XML.prototype.ignorewhite = true;
system.useCodepage = true;
Stage.scaleMode = "noScale";
if ((w == "") || (w == null)) {
w = 560;
}
if ((h == "") || (h == null)) {
h = 380;
}
_cxpos = 0;
_cypos = 0;
if ((f == "") || (f == null)) {
f = "puzzle.xml";
}
sys_maxatm = 777;
sys_curatm = 0;
if (initXML != "") {
aparm = new XML(initXML);
_root.gotoAndPlay("lrun");
} else {
aparm = new XML();
aparm.load(f);
}
Frame 4
if (!aparm.loaded) {
sys_curatm++;
if (sys_curatm > sys_maxatm) {
_root.gotoAndStop("lerr");
} else {
_root.gotoAndPlay("lwait");
}
}
Frame 5
function getLevel(pobj) {
if (pobj.level == null) {
pobj.level = 0;
} else {
pobj.level++;
}
return(pobj.level);
}
function drawLine(pobj, x1, y1, x2, y2, color) {
with (pobj) {
lineStyle(0, color);
moveTo(x1, y1);
lineTo(x2, y2);
}
}
function isOverObject(obj, cur_obj) {
if ((((cur_obj._x > (obj._x + 1)) && (cur_obj._x < ((obj._x + obj._width) - 1))) && (cur_obj._y > (obj._y + 1))) && (cur_obj._y < ((obj._y + obj._height) - 1))) {
return(true);
}
return(false);
}
function xImageLoad(name, itype, targ) {
if (name.charAt(0) == "_") {
if (itype != "") {
itype = "_" + itype;
}
targ.attachMovie(name + itype, name + itype, 0);
} else {
if (itype != "") {
itype = "/" + itype;
}
loadMovie (((basePath + name) + itype) + ".jpg", targ);
}
}
function xImageUnload(targ) {
unloadMovie (targ);
}
function placeBlocks() {
bnum = 0;
by1 = 0;
while (by1 < 5) {
bx1 = 0;
while (bx1 < 5) {
bnum++;
_root["b" + bnum]._x = (((bx1 * blockLength) + zoneXoffset) + blockSize) + 1;
_root["b" + bnum]._y = (((by1 * blockLength) + zoneYoffset) + blockSize) + 1;
_root["b" + bnum]._rotation = 0;
desk_maska[(by1 * 5) + bx1] = bnum;
_root["b" + bnum]._visible = true;
bx1++;
}
by1++;
}
}
function defMenuBox(obj, n, x, y) {
obj.createEmptyMovieClip(n, getLevel(obj));
obj[n]._x = x;
obj[n]._y = y;
obj[n].iname = -1;
with (obj[n]) {
lineStyle(0, menuBoxColor);
beginFill(menuBoxColor);
moveTo(0, 0);
lineTo(0, menuBoxSize);
lineTo(menuBoxSize, menuBoxSize);
lineTo(menuBoxSize, 0);
lineTo(0, 0);
endFill();
}
obj[n].createEmptyMovieClip("icon", 0);
obj[n].onRelease = function () {
if (this.iname != -1) {
playSound("s_click");
_root.startGame(this.iname);
}
};
obj[n].setIcon = function (niname) {
if (this.iname != -1) {
xImageUnload(this.icon);
}
if (niname != -1) {
xImageLoad(_root.desk_icons[niname], "", this.icon);
}
this.iname = niname;
};
}
function addMenuBoxes() {
indm = 0;
mindy = 0;
while (mindy < 2) {
mindx = 0;
while (mindx < 2) {
kindy = menuSelBoxY + ((menuBoxSize + menuSelBoxDY) * mindy);
kindx = menuSelBoxX + ((menuBoxSize + menuSelBoxDX) * mindx);
indm++;
defMenuBox(_root.selector, "m" + indm, kindx, kindy);
mindx++;
}
mindy++;
}
}
function setMenuIcons() {
indm = 1;
while (indm < 5) {
itic = (_root.firstIcon + indm) - 1;
if (itic < desk_icons.length) {
ziname = itic;
} else {
ziname = -1;
}
_root.selector["m" + indm].setIcon(ziname);
indm++;
}
if (_root.firstIcon == 0) {
_root.selector.prevI._visible = false;
} else {
_root.selector.prevI._visible = true;
}
if ((_root.firstIcon + 4) < desk_icons.length) {
_root.selector.nextI._visible = true;
} else {
_root.selector.nextI._visible = false;
}
}
function nextS() {
playSound("s_click");
firstIcon = firstIcon + 4;
setMenuIcons();
}
function prevS() {
playSound("s_click");
firstIcon = firstIcon - 4;
setMenuIcons();
}
function addWorkPanel(obj, n, x, y, w, h, color) {
obj.createEmptyMovieClip(n, getLevel(obj));
obj[n]._x = x;
obj[n]._y = y;
obj[n].selected = null;
obj[n].tabEnabled = false;
with (obj[n]) {
beginFill(color);
moveTo(0, 0);
lineTo(w, 0);
lineTo(w, h);
lineTo(0, h);
lineTo(0, 0);
endFill();
}
}
function addBlock(obj, fnum, xp, x, y) {
bn = "b" + fnum;
obj.createEmptyMovieClip(bn, getLevel(obj));
with (obj[bn]) {
lineStyle(0, _boxline);
beginFill(_boxfill);
moveTo(-xp, -xp);
lineTo(xp, -xp);
lineTo(xp, xp);
lineTo(-xp, xp);
lineTo(-xp, -xp);
endFill();
}
obj[bn]._x = x;
obj[bn]._y = y;
obj[bn].bnum = fnum;
obj[bn].createEmptyMovieClip("pic", 0);
obj[bn].pic._x = -xp;
obj[bn].pic._y = -xp;
obj[bn].moving = false;
obj[bn].rotating = false;
obj[bn].rad = xp * xp;
obj[bn].oldangle = 0;
obj[bn].rotactive = false;
obj[bn].onPress = function () {
if (!gameStarted) {
return(undefined);
}
if (startTime == 0) {
startTime = getTimer();
}
_root.dlevel++;
this.swapDepths(_root.dlevel);
radius = (this._xmouse * this._xmouse) + (this._ymouse * this._ymouse);
if (radius > this.rad) {
this.rotating = true;
this.oldangle = Math.atan2(this._ymouse, this._xmouse);
} else {
if (!this.moving) {
if (isOverObject(_root.main, this)) {
bx1 = Math.floor((this._x - zoneXoffset) / blockLength);
by1 = Math.floor((this._y - zoneYoffset) / blockLength);
desk_maska[(by1 * 5) + bx1] = 0;
}
}
this.moving = true;
this.startDrag(false, 0, 0, w, h);
}
};
obj[bn].onRelease = function () {
if (!gameStarted) {
return(undefined);
}
if (this.moving) {
iflag = false;
if (isOverObject(_root.work, this)) {
iflag = true;
}
if (isOverObject(_root.main, this)) {
bx1 = Math.floor((this._x - zoneXoffset) / blockLength);
by1 = Math.floor((this._y - zoneYoffset) / blockLength);
if (desk_maska[(by1 * 5) + bx1] == 0) {
this._x = (((bx1 * blockLength) + zoneXoffset) + blockSize) + 1;
this._y = (((by1 * blockLength) + zoneYoffset) + blockSize) + 1;
desk_maska[(by1 * 5) + bx1] = this.bnum;
iflag = true;
}
}
if (!iflag) {
return(undefined);
}
} else {
this._rotation = Math.round(this._rotation / 90) * 90;
}
playSound("s_drop");
this.moving = false;
this.rotating = false;
this.stopDrag();
testGoal();
};
obj[bn].onMouseMove = function () {
if (!gameStarted) {
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].onReleaseOutside = obj[bn].onRelease;
}
function resetBlocks(wt) {
_root.waitcnt = wt;
_root.areaClear = false;
_root.gotoAndPlay("mixup");
}
function testGoal() {
ix = 1;
while (ix <= totalBlocks) {
if ((desk_maska[ix - 1] != ix) || (_root["b" + ix]._rotation != 0)) {
return(false);
}
ix++;
}
if (sound_f && (musicBgr != "")) {
musicBgr = "";
_root._musicBgr.stop();
}
playSound("s_win");
gameStarted = false;
_root.work._visible = false;
_root.wwin._visible = true;
totTime = Math.floor((getTimer() - startTime) / 1000);
zsec = totTime % 60;
if (zsec < 10) {
psec = "0" + zsec;
} else {
psec = "" + zsec;
}
_root.wwin.timer.text = (("" + Math.floor(totTime / 60)) + ":") + psec;
gameFinished = true;
}
function playMusic() {
if (sound_f && (musicBgr != "")) {
_root._musicBgr.setVolume(100);
_root._musicBgr.start(0, 777);
}
}
function playSound(name) {
if (sound_f) {
_root[name].setVolume(100);
_root[name].start();
}
}
function startGame(xindm) {
_root.musicBgr = _root.desk_music[xindm];
if (_root.musicBgr != "") {
if (_root.desk_rand[xindm] != 0) {
suf = "" + random(_root.desk_rand[xindm]);
} else {
suf = "";
}
_root.musicBgr = _root.musicBgr + suf;
if (_root.musicBgr.charAt(0) == "_") {
_root._musicBgr.attachSound(_root.musicBgr);
} else {
_root._musicBgr.loadSound((basePath + _root.musicBgr) + ".mp3", false);
}
}
indm = _root.desk_icons[xindm];
xImageLoad(indm, "targ", _root.targ.img);
_root.selector._visible = false;
_root.work._visible = true;
placeBlocks();
idx = 1;
while (idx <= totalBlocks) {
xImageLoad(indm, "p" + idx, _root["b" + idx].pic);
idx++;
}
startTime = 0;
gameFinished = false;
resetBlocks(0);
}
function fbtn3() {
if (sound_f) {
if (musicBgr != "") {
_root._musicBgr.stop();
}
playSound("s_click");
sound_f = false;
} else {
sound_f = true;
if (musicBgr != "") {
_root._musicBgr.setVolume(100);
_root._musicBgr.start(0, 777);
}
playSound("s_click");
}
_root.btn3._visible = !_root.btn3._visible;
_root.btn3off._visible = !_root.btn3off._visible;
}
function fbtn1() {
if (gameStarted || (gameFinished)) {
if (sound_f && (musicBgr != "")) {
_root._musicBgr.stop();
}
playSound("s_click");
if (_root.targ.img != null) {
xImageUnload(_root.targ.img);
}
idx = 1;
while (idx <= totalBlocks) {
_root["b" + idx]._visible = false;
xImageUnload(_root["b" + idx].pic);
idx++;
}
_root.selector._visible = true;
_root.work._visible = false;
gameStarted = false;
if (gameFinished) {
_root.wwin._visible = false;
gameFinished = false;
}
}
}
function fbtn2() {
if (gameStarted) {
playSound("s_click");
resetBlocks(_root.maxwaitcnt);
}
}
menuBoxSize = 64;
menuBoxColor = 15782051 /* 0xF0D0A3 */;
menuSelBoxX = 12;
menuSelBoxY = 45;
menuSelBoxDX = 15;
menuSelBoxDY = 15;
totalBlocks = 25;
blockSize = 37;
blockLength = 74;
zoneXoffset = 185;
zoneYoffset = 5;
_boxline = 15782051 /* 0xF0D0A3 */;
_boxfill = 13408614 /* 0xCC9966 */;
_bgrfill = 15517068 /* 0xECC58C */;
firstIcon = 0;
gameStarted = false;
gameFinished = false;
startTime = 0;
sound_f = true;
basePath = "";
waitcnt = 0;
maxwaitcnt = 12;
musicBgr = "";
_musicBgr = null;
areaClear = false;
desk_maska = new Array();
desk_icons = new Array();
desk_music = new Array();
desk_rand = new Array();
s_mix = new Sound();
s_mix.attachSound("snd_mix");
s_drop = new Sound();
s_drop.attachSound("snd_drop");
s_click = new Sound();
s_click.attachSound("snd_click");
s_win = new Sound();
s_win.attachSound("snd_win");
_musicBgr = new Sound();
var parm_node = aparm.firstChild;
while (parm_node != null) {
if (parm_node.nodeName == "item") {
desk_icons.push(parm_node.attributes.n);
mel = parm_node.attributes.m;
rnd = parm_node.attributes.r;
if (mel == null) {
mel = "";
}
if (rnd == null) {
rnd = "0";
}
desk_music.push(mel);
desk_rand.push(rnd);
}
if (parm_node.nodeName == "base") {
basePath = parm_node.attributes.n;
}
parm_node = parm_node.nextSibling;
}
_root.btn3._visible = false;
_root.wwin._visible = false;
addWorkPanel(_root, "main", zoneXoffset, zoneYoffset, 370, 370, _boxfill);
xcnt = 5;
whe = blockLength;
ix = 0;
while (ix < (xcnt + 1)) {
drawLine(_root.main, 0, whe * ix, (whe * xcnt) - 1, whe * ix, _boxline);
ix++;
}
ix = 0;
while (ix < (xcnt + 1)) {
drawLine(_root.main, whe * ix, 0, whe * ix, (whe * xcnt) - 1, _boxline);
ix++;
}
addWorkPanel(_root, "targ", 73, 267, 100, 100, _boxfill);
_root.targ.createEmptyMovieClip("img", 0);
addWorkPanel(_root, "work", 12, 55, 162, 190, _bgrfill);
_root.work._visible = false;
idx = 1;
while (idx <= totalBlocks) {
addBlock(_root, idx, blockSize, blockSize + 14, blockSize + 57);
_root["b" + idx]._visible = false;
idx++;
}
dlevel = level;
addMenuBoxes();
setMenuIcons();
stop();
Frame 6
stop();
Frame 8
if (_root.waitcnt == 0) {
flg = 0;
plcnt = 1;
while (plcnt <= _root.totalBlocks) {
if (_root["b" + plcnt].pic.getBytesTotal() != _root["b" + plcnt].pic.getBytesLoaded()) {
flg = 1;
}
plcnt++;
}
if (flg == 0) {
_root.waitcnt++;
}
_root.gotoAndPlay("mixup");
} else {
_root.waitcnt++;
if (_root.waitcnt < _root.maxwaitcnt) {
_root.gotoAndPlay("mixup");
} else if (_root.areaClear) {
_root.gameStarted = true;
_root.playMusic();
_root.gotoAndPlay("lmain");
} else {
blk = random(_root.totalBlocks) + 1;
if (_root.desk_maska[blk - 1] == 0) {
sblk = blk + 1;
if (sblk > _root.totalBlocks) {
sblk = 1;
}
while (_root.desk_maska[sblk - 1] == 0) {
if (sblk == blk) {
_root.areaClear = true;
break;
}
sblk++;
if (sblk > _root.totalBlocks) {
sblk = 1;
}
}
blk = sblk;
}
if (!_root.areaClear) {
_root.playSound("s_mix");
zblk = _root.desk_maska[blk - 1];
_root["b" + zblk]._x = (_root.blockSize + 14) + random(160 - (_root.blockSize * 2));
_root["b" + zblk]._y = (_root.blockSize + 57) + random(188 - (_root.blockSize * 2));
_root["b" + zblk]._rotation = 90 * random(4);
_root.desk_maska[blk - 1] = 0;
_root.dlevel++;
_root["b" + zblk].swapDepths(_root.dlevel);
}
_root.gotoAndPlay("mixup");
}
}
Frame 9
_root.createTextField("terr", 0, _root._cxpos, _root._cypos, 200, 40);
_root.terr.text = "ERROR! Cannot load xml file";
stop();
Symbol 11 MovieClip Frame 1
this.ltot.text = Math.floor(_root.getBytesTotal() / 1024) + "Kb";
Symbol 11 MovieClip Frame 2
if (_root.getBytesTotal() == _root.getBytesLoaded()) {
_root.gotoAndPlay(2);
} else {
this.lproc.text = Math.floor((_root.getBytesLoaded() / _root.getBytesTotal()) * 100);
}
Symbol 11 MovieClip Frame 17
gotoAndPlay (2);
Symbol 98 MovieClip Frame 1
stop();
Symbol 107 Button [but]
on (release) {
fbtn1();
}
Symbol 112 Button [breset]
on (release) {
fbtn2();
}
Symbol 119 Button [bsound_on]
on (release) {
fbtn3();
}
Symbol 126 Button
on (release) {
getURL ("http://www.ztor.com", "_blank");
}
Symbol 131 Button [bsound_off]
on (release) {
fbtn3();
}
Symbol 136 Button [nextSet]
on (release) {
_root.nextS();
}
Symbol 140 Button [prevSet]
on (release) {
_root.prevS();
}