Can an index from one array, be joined with an index in a different array in response to, or followi
Can an index from one array, be joined with an index in a different array in response to, or following, a keyboard event?
I have two arrays, Array 1 (cvcwords ), displays a series of words, each time the Enter key is pressed, a new word is presented.
[When the pupil fails to read the word correctly the tester hits the SPACE Key. This brings up a text input box for the tester to type in the pupil’s incorrect response to the word presented] Array 2 (cvctextinputarray ),contains a series of functions. Each of these functions is directly related to each of the words from Array 1. For example if the word lap is presented and the pupil says lip, The tester hits the SPACE key which should bring the pupilsResponseLIP() function into action showing an input text box to receive the pupil’s incorrect response. Otherwise the tester would hit the ENTER key and a correct response would be recorded and a new word displayed.
No matter what way I do this I am unable to get the correct function from Array 2 to display with the appropriate word from Array 1. They need to be linked so that the wrong function does not get linked to the wrong word.
To help with this I have coded the text boxes to show whether they are the correct input box for the correct word when I run the program. Can anybody help with this? I include the main bits of code below;
public class ActivityScreen extends SceneBase {
private var textfield = String;
private var cvcwords : Array;
private var myTextIN : String = "Type pupil's response to IN";
private var myTextAT : String = "Type pupil's response to AT";
private var myTextOR : String = "Type pupil's response to OR";
private var myTextLAP : String = "Type pupil's response to LAP";
var cvcwords : Array = ["in", "at", "or", "lap", "ut", "rot", "get","hug","dam","fix","pot",];
var cvctextinputarray : Array = [pupilsResponseIN, pupilsResponseAT, pupilsResponseOR, pupilsResponseLAP, pupilsResponseUT, pupilsResponseROT, pupilsResponseGET, pupilsResponseHUG, pupilsResponseDAM, pupilsResponseFIX, pupilsResponsePOT,];
stage.addEventListener(KeyboardEvent.KEY_DOWN, arrayKeyDown);
function arrayKeyDown(e : KeyboardEvent) : void {
if (e.keyCode == Keyboard.ENTER) {
myText.text=cvcwords[counter];
addChild(myText);
counter++;
removeChild(myInputBox);//This will remove any textbox from previous word error inputs
}
else if (e.keyCode == Keyboard.SPACE ) {
cvctextinputarray[counter].call();
counter++
}
}
function pupilsResponseIN() : void {
myInputBox;
TextInput;
myInputBox.text = myTextIN;
addChild(myInputBox);
}
function pupilsResponseAT() : void {
myInputBox;
TextInput;
myInputBox.text = myTextAT;
addChild(myInputBox);
}
function pupilsResponseOR() : void {
myInputBox;
TextInput;
myInputBox.text = myTextOR;
addChild(myInputBox);
}
function pupilsResponseLAP() : void {
myInputBox;
TextInput;
myInputBox.text = myTextLAP;
addChild(myInputBox);
}
}