I am trying to use AS to create a hangman type game. I am wondering if it is possible to dynamically create a text field (mc.createTextField?) but then duplicate the mc that holds the text field?
I have this so far on the “submit” button (after user submits a letter):
on (release) {
//evaluate if guess matches letter in word
for (k=0; k<stringlen; k++) {
if (guess == guessword.charAt(k)) {
x = getProperty(_root.word["lines"+k], _x);
y = getProperty(_root.word["lines"+k], _y);
_root.createEmptyMovieClip("lettermc", 5);
lettermc.createTextField("letters"+k, k+5, x, y, 10, 20);
lettermc["letters"+k].text = guess;
status.text = "Lucky guess!";
guess = "";
} else {
status.text = "Try again!";
guess = "";
}
}
}
This works but only for the first letter in the word. Also, even if I guess the first letter it appears but at 0,0 (instead of x, y) and status.text shows up as “Try again!” instead of “Lucky guess!”.
- what do I need to fix
- how can I duplicate the text field to print out more letters?
Thanks for any help!
p.s. I can upload the whole fla if that would help.