Can an index from one array, be joined with an index in a different array in response to, or followi
can index 1 array, joined index in different array in response to, or following, keyboard event?
i have 2 arrays, array 1 (cvcwords ), displays series of words, each time enter key pressed, new word presented.
[when pupil fails read word correctly tester hits space key. brings text input box tester type in pupil’s incorrect response word presented] array 2 (cvctextinputarray ),contains series of functions. each of these functions directly related each of words array 1. example if word lap presented , pupil says lip, tester hits space key should bring pupilsresponselip() function action showing input text box receive pupil’s incorrect response. otherwise tester hit enter key , correct response recorded , new word displayed.
no matter way unable correct function array 2 display appropriate word array 1. need linked wrong function not linked wrong word.
to have coded text boxes show whether correct input box correct word when run program. can this? include 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 in";
private var mytextat : string = "type pupil's response at";
private var mytextor : string = "type pupil's response or";
private var mytextlap : string = "type pupil's response 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);
}
}
not sure if understand problem here simple example how convert strings functions:
import flash.events.mouseevent;
var arr:array = ["f0"];
function f0():void
{
trace("function 0 executed");
}
btn.addeventlistener(mouseevent.click, functionhandler);
//this grabs contents of the input-text , looks if there function available same name
function functionhandler(e:mouseevent):void
{
//check if function available
if (arr.indexof(input_txt.text)!=-1)
{
this[input_txt.text]();
}
else
{
trace("this no valid function");
}
}
More discussions in ActionScript 3
adobe
Comments
Post a Comment