0
public class Hangman extends Sprite {
private var textDisplay:TextField;
private var phrase:String = "Recycled"
private var phrase:String = "Stamped"
private var phrase:String = "grandpa"
「我想在這裏做的是隨機化‘這句話的數組:字符串’,這樣這句話的結果將被要麼回收,蓋章或爺爺隨機化從ActionScript
private var shown:String;
private var numWrong:int;
public function Hangman() {
// create a copy of text with _ for each letter
shown = phrase.replace(/[A-Za-z]/g,"_");
numWrong = 0;
...codes*
}
public function pressKey(event:KeyboardEvent) {
// get letter pressed
var charPressed:String = (String.fromCharCode(event.charCode));
// loop through nd find matching letters
var foundLetter:Boolean = false;
for(var i:int=0;i<phrase.length;i++) {
if (phrase.charAt(i).toLowerCase() == charPressed) {
// match found, change shown phrase
shown = shown.substr(0,i)+phrase.substr(i,1)+shown.substr(i+1);
foundLetter = true;
}
}
// update on-screen text
textDisplay.text = shown;
// update hangman
if (!foundLetter) {
numWrong++;
character.gotoAndStop(numWrong+1);
}
}
}
}
我希望有人能幫助我在這一個,謝謝。
@akmozo固定,感謝擡起頭.. – Bonatti
感謝您的幫助!我做到了,支架應該是方形支架而不是大括號。 :) – Confuser
@Confuser是的,就像akmozo說的,已經修復。祝你好運 – Bonatti