As soon as I solve one problem I appear to get three more to take its place. In my case I have been working on a particular program which , will ultimately involve about 150 different frames, each displaying a single word.
The sequence of actions is quite simple but the navigation is almost entirely controlled by key presses. in fact, It depends entirely on key presses.
Briefly (although nothing to do with this is ever brief), what needs to happen is as follows;
The user is a tester and there is a pupil observing a screen.
The screen presents a word;
The pupil says what he/she thinks that word is;
If they say the correct word the tester hits the ENTER key (This will add scores to a whole set of variables showing correct responses etc.)
If the pupil does not say the correct word then another key is pressed the “N” key which will make a text input box appear, and into which the pupil’s response is typed in by the tester. When the tester has finished typing in the pupil’s response he presses the SPACE key which will move on the display to a new frame showing a new image and so on.
Easy as pie you might say but in fact this has thrown up a huge set of problems to overcome and as soon as one has been resolved it has given rise to three more in its solution to the point where I am wondering did I chose the wrong set of tools to carry out this project.
If I may outline the problems;
First the program ignores the ENTER key the BACKSPACE key and a few others even their Numbers etc. and ‘I’m using a MacBook Pro so perhaps that may be the problem there but I cant disable the keyboard shortcuts no matter what I try . The ENTER key is vital to the program but for the past while I have tried to continue with the build on just 4 separate frames using the M key , to move to next frame, the N key to indicate an incorrect response and show Text input box, and then the SPACE key to continue to next frame after entering pupil’s response.
Then all hell breaks loose. There are the most amazing series of problems, which arise with this. For example;
Sometimes the last frames textbox continues into the next frame even though I have set its value and background equal to “ “ .
If the user accidently hits the space key before the N key and is moved on to next frame. I have built in a back option using the LEFT key. But even though the user enters the previous frame again. None of the code associated with that frame will work the second time round.
Setting down a simple sequence of key presses which, must be followed is then an option to work on so I have tried to set the sequence that the user must first hit the N key and then the SPACE key before moving on. But the program will not obey. I’m stuck on getting this very basic stuff off the ground a long time. I hate to admit since Christmas. I don’t give up easily and I wont with this either but I have to admit I might have made the wrong choice of tools. Navigation using key presses is rife with problems. There must be a way though.
My questions are;
Why does the Return/ENTER key not behave as it should? (it moves on to the next frame bypassing /ignoring all code and traces.
On the control menu options there is no option to disable the keyboard shortcuts. This is supposed to help as a means to getting the ENTER key to work as required. Nor is there even advice available on this in the help menu, when Disable Keyboard shortcuts is typed in.
Is it possible to set up a sequence of key presses so that the user, for example, must press the N key first and then type in to the text box, and then the SPACE key, to move on. If any other key is hit besides those keys, that a message will appear, and the user will be prevented from accidently moving on.
Finally, if the user has moved on, and wishes to revisit the last frame, to do it over again. Can that not work using the LEFT arrow key and the code for that frame , work as before?
Thanks in anticipation to anybody who feels like having a go at this.
Yes my apologies , I should be more specific about my question anyway. What I am asking is as follows;
Each frame has its own unique set of code in the Actions Window, and that will be enacted and that code will conduct its analysis on the particular text that has been input by the tester for the word that has been presented. It will for example, check whether the word input by the tester matches a word in an array of words. And so on.
But lets say, that the tester accidentally hit the ENTER key or perhaps the SPACE key inadvertently, as can frequently happen, bringing him forward one frame and he wants to re run the last frame and present it again to the pupil so that they can have another go at that particular word.
Now I tried to put code in place to cater for that by setting up a key that will return the tester to the last frame. However even though it works, it brings the user back to the previous frame. But the code for the previous frame no longer works.
I am including the Actions code for the frame which presents the word “at” to the pupil. The other frames code will differ in that the variables will contain the word that they are presenting on their specific frame.
stop();
var myVowela:Vowela = new Vowela();
var wordisAT:String = "at";
stop();
//Variable to store what the user types
var textAtAT:String = " ";
//var myVowela:Vowela = new Vowela();
//create input text field
var pupilsResponseAT:TextField = new TextField();
addChild(pupilsResponseAT);
//add listeners, one for change, one for enter
function changeHandlerAT(e:Event):void
{
// update var
textAtAT = pupilsResponseAT.text;
mainText.text = myVowela.vowelA(pupilsResponseAT.text);
trace( "input text= " + textAtAT);
}
function keyPressedAT(event:KeyboardEvent):void
{
if (event.keyCode == 13 ) /*this will move straight on to the next frame-
recording a correct response and all that that implies in terms of scores etc*/
{
//insert code for correct responses vowels etc.
stage.focus = stage;
//There is no need to display the text box as this is a correct response.
pupilsResponseAT.visible = false;
mainText.visible = false;
textAtAT = "at"
//pupilsResponseAT.text = "";
//pupilsResponseAT.background = "";
gotoAndPlay(3);
trace("ENTER key pressed move on correct response = " +textAtAT);
}
else if (event.keyCode == 78 )/* Tester hits the "N" key to signify that they wish
to input the pupil's response into the text box.Text box will appear*/
{
pupilsResponseAT.visible = true;
mainText.visible = true;
addEventListener(Event.ENTER_FRAME, handleEnterFrameAT);
}
{
if (event.keyCode == 32 ) /* Tester hits the SPACE key to move on after input text.
Need to build in something to prevent accidental hits on SPACE key.*/
{
//check whether the correct word was input or not and begin analysis on incorrect response
stage.focus = stage;
pupilsResponseAT.text = "";
pupilsResponseAT.background = "";
gotoAndPlay(3);
trace("Moving on after type of error e.g. bd confusion etc checked: " +textAtAT);
}
if (event.keyCode == 37 )// The LEFT ARROW key to bring back to previous frame
{
//In case the tester wants to return to the last frame to try it again
stage.focus = stage;
pupilsResponseAT.text = "";
pupilsResponseAT.background = "";
gotoAndPlay(1);
trace("Go back to previous frame to try it again ");
}
function handleEnterFrameAT(e:Event):void
{
removeEventListener(Event.ENTER_FRAME,handleEnterFrameAT);
stage.focus = pupilsResponseAT;
}
}
}
North America
Europe, Middle East and Africa
Asia Pacific