The code behind Steven's Matching Game
 
// Steven bday2002 matching10.fla :: global to movie (frame 8) :: 02-07-02
					
// array of position coordinates
pos1 = new Array (50,50);
pos2 = new Array (190,50);
pos3 = new Array (330,50);
pos4 = new Array (470,50);
pos5 = new Array (610,50);
pos6 = new Array (750,50);
pos7 = new Array (50,211);
pos8 = new Array (190,211);
pos9 = new Array (330,211);
pos10 = new Array (470,211);
pos11 = new Array (610,211);
pos12 = new Array (750,211);
pos13 = new Array (50,372);
pos14 = new Array (190,372);
pos15 = new Array (330,372);
pos16 = new Array (470,372);
pos17 = new Array (610,372);
pos18 = new Array (750,372);


// array of positions
aPos = new Array 
(pos1,pos2,pos3,pos4,pos5,pos6,pos7,pos8,pos9,pos10,pos11,pos12,pos13,pos14,pos15,pos16,pos17,pos18);


// game variables
var pick1 = "";
var pick2 = "";
var obj1 = "";
var obj2 = "";
var numofMatches = 0;
var numofMissMatches = 0;
var totalMatches = 0;
var totalMisses = 0;

function shuffle () {
return Math.floor(Math.random()*3)-1;
}

function resetGame () {
pick1 = "";
pick2 = "";
obj1 = "";
obj2 = "";
numofMatches = 0;
numofMissMatches = 0;
_root.numberofmatches = 0;
_root.numberofmisses = 0;
_root.phdone.removeMovieClip();

aPos.sort(shuffle);
_root.myarray = aPos;

j = -1;
for (i=1;i<10;i++) {    // i = clips to be duped
j++;                    // j = total clips on grid OR num of positions
_root["pic" + i].duplicateMovieClip ("p" + j, j);
_root["p" + j]._x = aPos[j][0];
_root["p" + j]._y = aPos[j][1];
trace ("i = " + i + ", j = " + j);
j++;
_root["pic" + i].duplicateMovieClip ("p" + j, j);
_root["p" + j]._x = aPos[j][0];
_root["p" + j]._y = aPos[j][1];
trace ("i = " + i + ", j = " + j);
}
_root.dupenomatch.duplicateMovieClip ("nomatch", j+1);
_root.nomatch._visible = false;
_root.nomatch._x = 274.9;
_root.nomatch._y = 160.8;
_root.dupematch.duplicateMovieClip ("ismatch", j+2);
_root.ismatch._visible = false;
_root.ismatch._x = 274.9;
_root.ismatch._y = 160.8;
}

function showAllPics () {     // before doneclip plays & btn on stage
for (i=0;i<19;i++) {
_root["p" + i].gotoAndStop ("show");
}
}

function hideAllPics () {     // after doneclip plays
for (i=0;i<19;i++) {
_root["p" + i].gotoAndStop ("hide");
}
}

function resetAllPics () {    // only used by button off stage
for (i=0;i<19;i++) {
_root["p" + i].gotoAndStop ("start");
}
}

function checkPick ( myPick, myObj ) {
if (pick1 == "") {            // 1st pick
pick1 = myPick;
obj1 = myObj;
_root.matchresult = "";
pick2 = "";
obj2 = "";
} else {                      // 2nd pick
pick2 = myPick;
obj2 = myObj;
checkMatch ( pick1, pick2 );
}
_root.numofMatches = numofMatches;
}

function checkMatch ( p1, p2 ) {
if ( p1 == p2 ) {      // matching pair
obj1.gotoAndStop ("hide");
obj2.gotoAndStop ("hide");
_root.matchresult = "Successful match!";
numofMatches = numofMatches + 1;
_root.numofMatches = numofMatches;
_root.numberofmatches = numofMatches;
if (numofMatches == 9) {
showAllPics ();
_level0.gotoAndStop ("end");    // hideAllPics is called in frame 55 of doneclip below
_root.phdone.attachMovie( "donecliplinkage", "donetest", 20);
}
_root.ismatch._visible = true;
_root.ismatch.play ();
} else {      // not a match
obj1.gotoAndStop ("start");
obj2.gotoAndStop ("start");
_root.matchresult = "NOT a match";
numofMissMatches = numofMissMatches + 1;
_root.numofMissMatches = numofMissMatches;
_root.numberofmisses = numofMissMatches;
_root.nomatch._visible = true;
_root.nomatch.play ();
}
pick1 = "";
}


// Steven bday2002 matching10.fla :: code in each of 8 pic clips (frame 12) :: 02-07-02

// identifies self to checkPick function
_level0.checkPick ("smile", this);
stop ();