PDA

View Full Version : Smoother scrolling on a key press.


Aki.
01-28-2011, 03:35 PM
Hey guys,

I'm currently trying to move an object on the stage up and down. Right now, it is working fine and the object does as it's told, but whenever I press the key to initiate movement the object moves once, pauses and then continues.

I think in order to fix this and get a smoother motion, I need to let the event handler take care of the motion for me but I'm not sure how to go about it.

I'm guessing I need a function that contains the key presses and essentially acts like an on/off switch telling the event handler function when to turn on or off up or down movement.

Does this make any sense? Any ideas on how I could go about getting this to work?

dialectric
01-31-2011, 01:11 PM
Hi,

One approach to getting smoother movement would be to have the key listeners just set a variable noting that the key is down, then handle all of the movement in an enter frame script. This would require a third listener to handle key up events, to reset the variables for the keys to up.

Running the movement this way should get around the lag before a key starts repeating, which is likely causing your issue.

- dialectric