Using two Arrays
As part of my Hangman game I want to have two Arrays, one holding the wordlist, and one holding the clues. What I intend to do, is randomly generate a word along with the clue to that word. I've got the word generator working correctly but I'm not sure how I can make it choose a clue from a seperate array. This is what I have so far to make the Array of words work:
var words: Array = ["LONDON", "CYPRUS", "CHINA"];
This is my Array of the words
number = (Math.floor(Math.random()* 3));
inProgress = words[number];
wordLength = inProgress.length;
This is what I use to randomly Generate the word. Note: number is a number variable I created and inProgress is a String variable I created.
I would like to know how I'm able to make it randomly generate the clue along with this, using the Array:
var clues: Array = ["Capital of England", "Small Island", "Highest population"];
If it makes it easier to see the whole code leading up to this I'll paste it below for you to see. Thanks!
var words: Array = ["LONDON", "CYPRUS", "CHINA"];
var number:Number;
var inProgress: String = new String;
var wordLength:Number;
var myDisplay: Array = new Array();
var displayOut: String = new String;
var rightCount: Number = 0;
var used: String = new String;
var guess: String = new String;
var guessLetter: String = new String;
var correctGuess: Boolean = false;
number = (Math.floor(Math.random()* 3));
inProgress = words[number];
currentClue = clues[number];
wordLength = inProgress.length;
for (var i = 0; i <wordLength; i ++)
{
myDisplay = "*";
displayOut += " " + myDisplay
}
var answerText:TextField = new TextField();
var myFormat:TextFormat = new TextFormat();
myFormat.font = "Segoe UI Symbol";
myFormat.color = 0X00FF00;
myFormat.size = 23;
addChild(answerText);
this.answerText.x = 375;
this.answerText.y = 40;
this.answerText.width =250;
this.answerText.text = displayOut;
answerText.setTextFormat(myFormat);
