Frame 1
highScore = 0;
Frame 3
function attachCards() {
i = 0;
while (i < 20) {
_root.attachMovie("card", "card" + i, i);
if ((((i == 5) || (i == 10)) || (i == 15)) || (i == 20)) {
Vrow++;
Hrow = 0;
}
_root["card" + i]._x = (_root["card" + i]._width * Hrow) + 1;
_root["card" + i]._y = (_root["card" + i]._height * Vrow) + 1;
_root["card" + i].id = i;
Hrow++;
i++;
}
}
function randomizeCards() {
i = 0;
while (i < 20) {
var _local5 = "no";
while (_local5 == "no") {
var _local4 = "no";
var _local3 = random(21);
if (_local3 != 0) {
j = 0;
while (j < 20) {
if (pictureNum[j] == _local3) {
_local4 = "yes";
}
j++;
}
if (_local4 == "no") {
pictureNum[i] = _local3;
_local5 = "yes";
}
}
}
_root["card" + i].onRelease = function () {
if (this.flipped != true) {
if (flipped < 2) {
if (flipped == 0) {
ident1 = this.id;
firstFlip = this.pictureNum;
this.gotoAndStop(this.pictureNum);
} else if (flipped == 1) {
if (this.id != ident1) {
ident2 = this.id;
secondFlip = this.pictureNum;
this.gotoAndStop(this.pictureNum);
} else {
flipped--;
}
}
}
flipped++;
if (flipped >= 2) {
if (firstFlip == secondFlip) {
_root["card" + ident1].flipped = true;
_root["card" + ident2].flipped = true;
flipped = 0;
flippedTotal++;
} else if (flipped == 3) {
_root["card" + ident1].flippBack = true;
_root["card" + ident2].flippBack = true;
flipped = 0;
}
tries++;
}
if (flippedTotal >= 10) {
if ((tries < highScore) || (highScore == 0)) {
highScore = tries;
}
gotoAndPlay (2);
}
}
};
i++;
}
}
function sortCards() {
i = 0;
while (i < 20) {
_root["card" + i].pictureNum = Math.ceil(pictureNum[i] / 2) + 1;
i++;
}
}
stop();
pictureNum = new Array(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
firstFlip = null;
flipped = 0;
flippedTotal = 0;
tries = 0;
Vrow = 0;
Hrow = 0;
attachCards();
randomizeCards();
sortCards();
startTime = getTimer();
Symbol 24 MovieClip [card] Frame 1
flippBack = false;
flipped = 0;
stop();
onEnterFrame = function () {
if (flippBack == true) {
gotoAndStop (1);
flippBack = false;
}
};
Symbol 33 Button
on (release) {
gotoAndPlay (2);
}