# Newbie needs help plz!

**URL:** <https://forum.kirupa.com/t/newbie-needs-help-plz/221439>\
**Category:** Uncategorized\
**Created:** [April 4, 2007, 11:26am UTC](https://forum.kirupa.com/t/newbie-needs-help-plz/221439 "2007-04-04T11:26:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![layfie](https://avatars.discourse-cdn.com/v4/letter/l/d2c977/32.png) [@layfie](https://forum.kirupa.com/u/layfie)\
**Post date:** [April 4, 2007, 11:26am UTC](https://forum.kirupa.com/t/newbie-needs-help-plz/221439/1 "2007-04-04T11:26:20Z")

</div>

Hi everyone, forgive me for asking for help as a first post but this is critical. I’m making a learning package for my degree and im incorporating a hangman game into it using this code:

initGame();  
stop();  
function initGame() {  
// get phrase  
phrase = “tsar nicholas II”;  
man.gotoAndStop(1);  
// build display  
display = “”;  
for(i=0;i\<phrase.length;i++) {  
// place spaces in the right spots  
if (phrase.charAt(i) == " ") {  
display = display + " ";  
} else {  
// place underscores in place of letters  
display = display + “\_”;  
}  
}  
}  
function makeGuess(code) {  
// get the character that corresponds to the key pressed  
letter = String.fromCharCode(code);  
// check to see whether it is a letter  
if (isAlpha(letter)) {  
// assume that the letter will not be found  
gotOne = false;  
// start building new display  
newDisplay = “”;  
for(i=0;i\<phrase.length;i++) {  
// see whether letters match  
if (phrase.charAt(i).toUpperCase() == letter.toUpperCase()) {  
// place letter in display text  
newDisplay = newDisplay + letter.toUpperCase();  
// note that at least one match has been found  
gotOne = true;  
} else {  
// not found, so display same character  
newDisplay = newDisplay + display.charAt(i) ;  
}  
}  
// show new display  
display = newDisplay;  
// if no match found, then add more to man  
if (!gotOne) {  
man.nextFrame();  
// see whether the man is done  
if (man.\_currentFrame == 8) {  
gotoAndPlay(“lose”);  
}  
} else if (display == phrase.toUpperCase()) {  
// the display matches the original, game over  
gotoAndPlay(“win”);  
}  
}  
}

// utility to test whether a character is in A-Z  
function isAlpha(letter) {  
// get character code  
n = letter.charCodeAt(0);  
// convert low case to upper case  
if (n \> 90) n -= 32;  
// see whether it is in A-Z  
return ((n \>= 65) and (n \<= 90));  
}

Does anybody know any way i could list loads of phrases and have the program randomly choose one of them rather than just one at a time?

e.g.  
tsar nicholas II  
winston churchill  
etc etc

Any help much appreciated,

Layfie!
