Frame 1
function melanger(contenu) {
tab1 = new Array();
tab1 = contenu.split(",");
_root.tab = new Array();
while (tab1.length != 0) {
alea = Math.floor(Math.random() * (tab1.length - 1));
_root.tab.push(tab1[alea]);
tab1.splice(alea, 1);
}
pieces2 = _root.tab.toString();
}
function deplace(piece, numero) {
_root.MCconteneur["MCpiece" + numero].frame = piece.frame;
_root.MCconteneur["MCpiece" + numero].gotoAndStop(piece.frame);
_root.MCconteneur["MCpiece" + numero].enabled = true;
if (_root.MCconteneur["MCpiece" + numero].frame == (_root.MCconteneur["MCpiece" + numero].carre + 1)) {
_root.MCconteneur["MCpiece" + numero].bienplacee = true;
} else {
_root.MCconteneur["MCpiece" + numero].bienplacee = false;
}
tab[numero] = tab[piece.carre];
tab[piece.carre] = 16;
piece.frame = 16;
piece.enabled = false;
piece.gotoAndStop(16);
comptePoints();
}
function comptePoints() {
points = 0;
for (i in _root.MCconteneur) {
if (_root.MCconteneur[i].bienplacee == true) {
points = points + 1;
}
}
if (points == 15) {
for (i in _root.MCconteneur) {
_root.MCconteneur[i].enabled = false;
}
_root.MCconteneur.MCpiece.enabled = true;
_root.MCconteneur.MCpiece15.gotoAndStop(17);
_root.MCconteneur.MCpiece15.enabled = true;
_root.MCconteneur.MCpiece15.onPress = function () {
melanger(pieces2);
jouer();
};
}
}
function jouer() {
cpt = 0;
i = 0;
while (i < nblignes) {
j = 0;
while (j < nbcolonnes) {
MCconteneur.MCpiece.duplicateMovieClip("MCpiece" + cpt, cpt);
_root.MCconteneur["MCpiece" + cpt]._x = 10 + (j * 125);
_root.MCconteneur["MCpiece" + cpt]._y = 10 + (i * 125);
_root.MCconteneur["MCpiece" + cpt].gotoAndStop(tab[cpt]);
_root.MCconteneur["MCpiece" + cpt].frame = tab[cpt];
_root.MCconteneur["MCpiece" + cpt].carre = cpt;
if (tab[cpt] == (cpt + 1)) {
_root.MCconteneur["MCpiece" + cpt].bienplacee = true;
}
if (cpt == 16) {
_root.MCconteneur["MCpiece" + cpt].enabled = false;
}
_root.MCconteneur["MCpiece" + cpt].onPress = function () {
if (tab[Number(this.carre) + 4] == 16) {
var dessous = (Number(this.carre) + 4);
var piece = this;
deplace(piece, dessous);
} else if (tab[Number(this.carre) - 4] == 16) {
var dessus = (Number(this.carre) - 4);
var piece = this;
deplace(piece, dessus);
} else if (tab[Number(this.carre) + 1] == 16) {
var droite = (Number(this.carre) + 1);
var piece = this;
deplace(piece, droite);
} else if (tab[Number(this.carre) - 1] == 16) {
var gauche = (Number(this.carre) - 1);
var piece = this;
deplace(piece, gauche);
}
};
cpt++;
j++;
}
i++;
}
MCconteneur._x = 110;
MCconteneur._y = 10;
MCconteneur._rotation = 15;
MCconteneur._yscale = 80;
MCconteneur._xscale = 80;
MCtextes._rotation = 15;
}
fscommand ("allowscale", "false");
fscommand ("fullscreen", "true");
nblignes = 4;
nbcolonnes = 4;
MCconteneur.MCpiece.stop();
MCconteneur.MCpiece.gotoAndStop(18);
MCconteneur.MCpiece.onPress = function () {
fscommand ("quit");
};
MCtextes.BTNmanara.onPress = function () {
getURL ("http://www.milomanara.it/", _blank);
};
MCtextes.BTNsaturnino.onPress = function () {
getURL ("http://www.saturnino-freelance.com/", _blank);
};
pieces = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16";
melanger(pieces);
melanger(pieces2);
jouer();