-
I'm trying to write an actionscript that will allow my swf movie to ask the user a multiple choice question and then accept a key input (a, b, or c) and then figure out if they picked the right answer. i've stored my questions in the array questionArray, and output the questions to some dynamic text boxes.
**the next step is to have my main loop wait for a user inputed key and then store that key to a var.**
i've tried several ways to do this with a do while loop and just a while loop, but they all crash flash. gah! i'm not sure if this is even the right way to approach the problem. anybody know what i should be doing differently?
this script is all stored in the first keyframe of my movie,
ultimatly this key will be compared to an array of answers, a score will be updated and the main loop will start again with the next question in questionArray.
questionArray = [
"what is this?",
"a: asdf",
"b: gbad",
"c: bsas",
"what is that?",
"a: lkbja",
"b: bha",
"c: bda"
];
for(i=0; i*4<questionArray.length; i++) {
j = i*4;
question = questionArray[j];
answerA = questionArray[j+1];
answerB = questionArray[j+2];
answerC = questionArray[j+3];
do {
keydown = true
if (Key.isDown(65)) {
keydown = false;
}
} while( keydown );
}
-
Senior Front End Developper
you could use the onClipEvent(keyUp) actions
just created an empty movie clip, right click on it, then select "actions".
in the actions windows, you can write actions for this clip (but in our case we will be writing global actions)
Code:
onClipEvent(keyDown)
{
code = Key.getCode();
if (code == 65)
//action for 'a'
else if (code == 66)
//actions for 'b'
//etc.
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|