PDA

View Full Version : hangman


jonjak
03-12-2002, 11:50 AM
i need some help to develope a simple hangman game!!
i have made an array that contains teh words that shal appeare,and made a random function. i also have the right number of textboxes(the same number as there are letters in the word) to appeare.
my problem is: how can i make the user select one letter at the time, and have flash to test if the word contains this letter or not?

sfa
03-12-2002, 12:13 PM
you need to split the sentence into an array of seperate letters using a substring in a for loop. Then just run through all of them usinf a for loop and an if statement to check for the particular letter.

SFA

jonjak
03-12-2002, 12:24 PM
ok... can u tel me how you do this?? i'm kinda newbee..

sfa
03-12-2002, 12:45 PM
imagine you have a variable with the phrase that needs to be guessed called "phrase". Then every leeter into an array something like this

for(i=1;i<phrase.length;i++){
phrasearray[i] = phrase.substr(i,1);
}

then to check if th letter selected exists do another for loop.

for(for(i=1;i<phrasearray.length;i++){
if(letterselected = prasearray[i]){
do whatever you want to do;
}
}

something like this

SFA