Skip to main content
Known Participant
March 19, 2009
Question

Trying to read if button is down

  • March 19, 2009
  • 3 replies
  • 356 views
My code initially has a timer generating an interupt ever 25 ms, on the interupt it calls a certain function. I am simply wanting to read if the button is down as opposed to having an interupt generated when the button is pressed. Is that possible, and if so why am I getting a bunch of errors with the attatched code. Any help is appreciated.
Thanks
This topic has been closed for replies.

3 replies

Inspiring
March 22, 2009
It seems that you are attempting listening of keyboard events when Timer event is fired. Timer doesn't have keyCode property.

You need to add listener to key board - not timer:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/KeyboardEvent.html

It also looks like there is wrong syntax. Did you mean to put "if" statement inside onTick function?
March 22, 2009
Why not use a toggle variable to see if the button was pressed. And then write a function that would keep checking the toggle status. My two cents.

Thanks.
Known Participant
March 21, 2009
Anyone have any suggestions, I am finding that I need to have an event listner but I do not want a function to be triggered when a button is pressed. I would prefer to check for it on a regular interupt that I can perform many other checks in as well.