Copy link to clipboard
Copied
I am having some troubles with my game, Where it says "To the north of you are trees.", "To the south of you are trees." I'd like to make those into - gotoAndStop(Frame); - options, but I don't know how? Can anyone help me?
stop();
var p1_answerArray:Array = ["Look North", "Look South"];
//Responses to those answers
var p1_answerArray2:Array = ["To the north of you are trees.", "To the south of you are trees."];
//Array of page texts
var p1_textArray:Array = ["You are standing in a clearing, there are trees on all sides of you."];
//Send page text to dnynamic field
this.readText.text = p1_textArray[0];
//Check the input Field on button press
this.enterBtn.onRelease = checkText;
function checkText() {
//Grab text from input field
var iT:String = inputText.text;
var ansGiven:Number;
//Loop through possible answers
for (a=0; a<p1_answerArray.length; a++) {
//If the inout text matches an answer
if (iT.toUpperCase() == p1_answerArray.toUpperCase()) {
//Return its corresponding text from the array
readText.text += "\r"+p1_answerArray2;
var foundAnswer:Boolean = true;
}
}
//Else it didn;t find an answer, so return a message
if (!foundAnswer) {
readText.text += "\r"+"I do not understand "+iT;
readText.text += "\r"+"Your available commands are: "+"\r"+p1_answerArray;
}
foundAnswer = false;
}
Kind Regards
Copy link to clipboard
Copied
Based on the line : this.enterBtn.onRelease = checkText;
you are probably posting in the wrong forum since that uses AS2 coding, not AS3. So if you have further questions you should take them up in the AS1/2 forum.
As far as having gotoAndStop(frame) entries, are you expecting the user to type that? I suspect not, so it is hard to tell what you are having a problem with doing relative to having those two strings in the array.
If it turns out that you want certain answers to produce certain results, you might want to consider a more complex data structure where you store objects in the array. Each object could have the expected input striing and the resulting action for that string being entered (in some coded form that you devise an interpreter for).