View Full Version : Reaction Timer.....
roy_geoff307
10-18-2005, 08:48 AM
First off I have searched this site, and found questoins similair to mine...but notrequesting thesame answer....
Anyway down to it:
I want to create a flash document that has a RED circle in the middle, when you click it, it starts a random timer say between 5 to 15 seconds, and when the timer has finished it:
1. Changes the circle to blue
2. Begin another timer which this time is displayed , on the screen (not on a separate window)
When you click the cricle again it will stop the timer, and take you to another scene/frame which displays
Your reaction time was xx.xx Seconds, (Very Good, Good, Not too bad)
The last set of brackets will be displayed depending on what the no. is.
for eg. <0.50 Very good | <or= 0.51 and >or=1.00 Good | >1.01 Not too bad
Any help would be greatly appreciated, and links, examples or anything, Thanks in advance,
Geoff, Eventually will be good at Flash.
Paerez
10-18-2005, 10:10 PM
I was bored at work so I did it for you.
Best I could do was 203ms
Here:
roy_geoff307
10-19-2005, 09:37 AM
Thats great, but can you tell me how to: a) Display the out put in a text box.
b)Stop it from going again, maybe to need a button to reset it.
Paerez
10-19-2005, 05:35 PM
a) Drag a text box to the screen. Make it dynamic text and link it to the variable "output" or whatever. Then replace:
trace("Your reaction time was: "+totalTime+"ms");
with
output = "Your reaction time was: "+totalTime+"ms";
b) Make a function that is the same as the goRed() function (call it disable() for example), except change the onRelease function to:
circle.onRelease = null;
That will disable it, then when you want to enable it, run goRed(). So maybe put a reset button on the stage that runs goRed() when it is clicked, so it re-enables the button.
roy_geoff307
10-19-2005, 11:27 PM
Thanks for your help so far, if you could keep chekin for a few more days..
Ive resolved on problem, i wanted to have message. eg if your time was less then 400 message = Good..etc
I worked this out...by:
function setmessage() {
if (output == 0)
Message="pure luck..or cheating?";
else if (output<=100 && output>0)
Message="is this superman playing?";
etc etc....
OK, now i need help (4th edit of this post..)
I am having trouble with your method of disabling the repeat...without the use of a button.
let me see if i have it straight:
Were the code is about goRed
replae that with a disable to look like:
" disable();
};
};
var disable = function () {
circle.gotoAndStop("red");
circle.onPress = null() {
randInterval = setInterval(goBlue, Math.random()*5000);
};
};
disable();
And then make a button, and in the btton code put:
" onrelease { goRed();
};
};
var goRed = function () {
circle.gotoAndStop("red");
circle.onPress = function() {
randInterval = setInterval(goBlue, Math.random()*5000);
};
};
goRed();
}
Is that what you mean?
Paerez
10-20-2005, 04:36 PM
Add this function at the end of the actionscript:
var disable = function() {
circle.gotoAndStop("red");
circle.onPress = null;
}
Now you can run it by typing:
disable();
That will disable it.
When you want to enable it again, run:
goRed();
roy_geoff307
10-20-2005, 11:31 PM
I have managed to make it run only once with the disable, tat worked great, i put the disable after the goRed code.., but before the go red command.
This works...
But when i make a button that is on.release goRed(); (right syntax though,,,)
it does not do a thing, once i run it i can only do the test once....
can i see the whole base code from trace/output......i get a bit with just snipits...
Paerez
10-21-2005, 12:00 AM
hmm weird. Can you post your current .fla up? Then I can get a better look at it. You have to zip it first, though. In windows you can right click and say "send to" -> "compressed folder".
roy_geoff307
10-21-2005, 07:26 AM
Here it is...
The problem is: that if you double click on it, or clck b4 it goes blue, it will go blue again, and agian etc etc....
The other proble is, when i put the disable in, the reset button doesnt work, so i have to exit, open to itry again.
roy_geoff307
10-21-2005, 09:41 AM
I have figured it all out, i have used nextscene(); and prevscene(); so no need for a disable function and a reset....Thanks heaps anyway....:)
I will atatch almost finished, just gotta make it look good
thanks heaps for all your help.
ps, the black rectangles are the forward (right) and back (left) buttons.
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.