Changing my Display...
ok! so, i've been developing hangman game quite time , how works. array of words, randomly generates 1 of words, converts underscores , creates spaces between each underscore. user has do, enter letter input text, push guess_btn , trace see if guessed letter equal 1 randomly selected. if is, convert letter , increase rightcount. if it's not, movie clip increase 1 moving closer person dying. sounds simple. problem have, though traces "true" on correct letter, "mydisplay" (which underscores) doesn't change underscore guessed letter. i'm gonna paste swath of code how think game should function, , i'm going highlight problem in code. or think is. want "oh, it's not changing underscores because..." please, please... please, me! haven't got long make game , need help! thank you!
stop();
var words: array = ["london", "cyprus", "china"];
//creates array of words choose from
var number:number;
var inprogress: string = new string;
var wordlength:number;
var mydisplay: array = new array();
var displayout: string = new string;
//store number correct guesses
var rightcount: number = 0;
//stores incorrect guesses
var used: string = new string;
//holds correct guess'd letter
var guess: string = new string;
//holds users correct guess
var guessletter: string = new string;
//holds status of guess
var correctguess: boolean = false;
number = (math.floor(math.random()* 3));
//generating random number
inprogress = words[number];
//stores current word in "inprogess" variable
wordlength = inprogress.length;
//calculates legnth of word
//for statement used when know how many times loop
(var = 0; <wordlength; ++)
{
mydisplay[i] = "_";
displayout += " " + mydisplay[i];
}
//creating text in text field used letters
var answertext:textfield = new textfield();
var myformat:textformat = new textformat();
myformat.font = "segoe ui symbol";
myformat.color = 0x00ff00;
myformat.size = 23;
//the location of text field
addchild(answertext);
this.answertext.x = 375;
this.answertext.y = 40;
this.answertext.width =250;
this.answertext.text = displayout;
answertext.settextformat(myformat);
this.guess_btn.addeventlistener(mouseevent.click, playme);
function playme(event:mouseevent):void
{
//switches letters capital
guessletter = this.letterin_txt.text.touppercase();
for(var = 0; i< wordlength; i++)
{
if(inprogress.charat(i) == guessletter)
{
trace("true");
mydisplay[i]=guessletter;
correctguess=true;
rightcount++;
}
}
}
if (correctguess==false)
{
used+= this.letterin_txt.text;
this.usedletters_txt.text = used;
this.comp.nextframe();
}
else
correctguess=false
displayout = "";
for(var c=0; c < wordlength; c++)
{
displayout += " " + mydisplay[c];
}
this.answertext.text= displayout;
this.answertext.settextformat(myformat)
this.letterin_txt.text = "";
if (rightcount == wordlength)
{
removechild(answertext)
//takes scene 2
gotoandstop(103)
}
in code highlighted, put: trace(mydisplay); , see progress thru game.
i don't see changing in array updates else, might related problem.
More discussions in ActionScript 3
adobe
Comments
Post a Comment