PDA

View Full Version : need help on matching game


wanzi
11-20-2002, 05:26 PM
I am doing a matching game which generates a random number from 0-999.
I will be making 10 buttons labelled from 0-9
Would like to ask what actionscript should i add so that, for example ,flash ask : please press 123
then when i press the button labelled 1 followed by the button labelled 2 followed by the button labelled 3 will bring me to a scene which shows congratulations.

Somebody please help .. if u have done similar game do reply ... will be grateful
Thanks a million.
:D

jimburton
11-20-2002, 08:11 PM
maybe have three seperate random numbers in an array and keep track of where you are in checking them...:

rands = new Array();
for (i=0;i<3;i++) {
rands.push(Math.floor(Math.random()*10));
}
n = 0;
function checkPress(pressed) {
if(pressed != rands[n]) {
gotoAndStop("oops");
} else if (n==rands.length-1) {
gotoAndStop("won");
} else {
n++;
}
}