Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wait for the user key press

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I need to detect how long it's been since the user pressed a key.

For example, if the user hasn't pressed a key for 5 seconds then do something, else, get the key code and do something else.

 
You need a bit of script in the time line which detects if a key has been pressed; all you need to do then is put the time it was pressed into a global variable. Next you need a bit of code to check this variable and do a whole load of if statements (as Flash doesn't have a case statement as far as I'm aware) to check on the time difference.

It'll look somewthing like this...and before you say I know this is in v. rough psuedo code but I have lots to do today and it's too long since I did any action script. =)


if key pressed then
'this needs to works out the seconds gap (which isn't too
'hard but certainly needs more than this single line of
'code!
pause_time = current_time - last_time_pressed

'this records the time so that when the next key is
'pressed the code above works!
last_time_pressed = current_time
end if

' now we have the time we have waited we can check on it...
' (this may need to go somewhere else to enable it to be
' checked correctly).
if pause_time = '3' then
go to and play something
end if
if pause_time = '5' then
go to and play soemthing
end if
.
.
.


Hopefully this will help; sorry I haven't the time to be of more use!

PetitPal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top