PDA

View Full Version : i can't win on hangman


tmanctt
04-19-2006, 08:11 PM
i am still working on this hangman game and we have everything working we have our count and arrays and everything except we can't figure out how to win the game. what i mean is when you guess all the letters and get them right we can't figure out the code to make it say you win. we have the movie clip that says you win and we have it invisible but don't know where or what if statement to put in to make it visible at when you win. here is the code

youwin._visible = false;
youlose._visible = false;
start._visible = false;
var count = 0;
txtcount.text = count;
score1._visible = false;
score2._visible = false;
score3._visible = false;
score4._visible = false;
score5._visible = false;
score6._visible = false;
score11._visible = true;
score12._visible = true;
score13._visible = true;
score14._visible = true;
score15._visible = true;
score16._visible = true;
function score() {
if (count == 1) {
score1._visible = true;
score11._visible = false;
}
if (count == 2) {
score2._visible = true;
score12._visible = false;
}
if (count == 3) {
score3._visible = true;
score13._visible = false;
}
if (count == 4) {
score4._visible = true;
score14._visible = false;
}
if (count == 5) {
score5._visible = true;
score15._visible = false;
}
if (count == 6) {
score6._visible = true;
score16._visible = false;
}
if (count == 6) {
youlose._visible = true;
start._visible=true;
}
txtcount.text = count;
}
win=false;

function find(alpha, theButton) {
if (txtDisplay1.text == alpha) {
txtDisplay1.textColor = 0x000000;
win = true;
}
if (txtDisplay2.text == alpha) {
txtDisplay2.textColor = 0x000000;
win = true;
}
if (txtDisplay3.text == alpha) {
txtDisplay3.textColor = 0x000000;
win = true;
}
if (txtDisplay4.text == alpha) {
txtDisplay4.textColor = 0x000000;
win = true;
}
if (txtDisplay5.text == alpha) {
txtDisplay5.textColor = 0x000000;
win = true;
}
foundSwitch = true;
for (i=0; i<6; i++) {
sap = newWord.charAt(i);
if (sap == alpha) {
foundSwitch = false;
(i) = 7;
}
}
if (foundSwitch == true) {
count = count+1;
}
// trace(foundSwitch);
// trace(count);
// }
if (count == 6) {
alphabet = "abcdefghijklmnopqrstuvwxyz";
for (x=0; x<26; x++) {
allButton = alphabet.charAt(x)+'Button';
// trace(allButton);
eval(allButton)._visible = false;
}
txtDisplay1.textColor = 0x000000;
txtDisplay2.textColor = 0x000000;
txtDisplay3.textColor = 0x000000;
txtDisplay4.textColor = 0x000000;
txtDisplay5.textColor = 0x000000;
}
theButton._visible = false;
// make all textbox black coz game is over
// make all alphabets dissapear
// tell them to press start again
}
function button() {
alphabet = "abcdefghijklmnopqrstuvwxyz";
for (x=0; x<26; x++) {
allButton = alphabet.charAt(x)+'Button';
// trace(allButton);
eval(allButton)._visible = false;
}
}
alphabet = "abcdefghijklmnopqrstuvwxyz";
for (x=0; x<26; x++) {
allButton = alphabet.charAt(x)+'Button';
// trace(allButton);
eval(allButton)._visible = false;
}
function makeVisible() {
alphabet = "abcdefghijklmnopqrstuvwxyz";
for (x=0; x<26; x++) {
allButton = (alphabet.charAt(x))+'Button';
// trace(allButton);
eval(allButton)._visible = true;
}
}
txtDisplay1._visible = false;
txtDisplay2._visible = false;
txtDisplay3._visible = false;
txtDisplay4._visible = false;
txtDisplay5._visible = false;

function display() {
txtDisplay1._visible = false;
txtDisplay2._visible = false;
txtDisplay3._visible = false;
txtDisplay4._visible = false;
txtDisplay5._visible = false;
}
function txtBoxAll() {
for (n=0; n<newWord.length+1; n++) {
switch (n) {
case 1 :
txtDisplay1._visible = true;
break;
case 2 :
txtDisplay2._visible = true;
break;
case 3 :
txtDisplay3._visible = true;
break;
case 4 :
txtDisplay4._visible = true;
break;
case 5 :
txtDisplay5._visible = true;
break;
case 6 :
txtDisplay6._visible = false;
break;
case 7 :
txtDisplay7._visible = false;
break;
}
}
}
stop();

Darcey
04-21-2006, 01:33 PM
not got time to go through all that..

Loop through your correct answers array or elements.. like so.
I would assume you are using arrays...

var win:boolean = true;

for (var i=0; i <= NoOfLettersInArray; i++)
{
if letter[i] != correctLetter[i])
{
win = false;
}
}