Copy link to clipboard
Copied
Hi everybody,
I am using Adobe Flash CS4. I just took a tutorial for keyboard input, and when I test my movie, the up key causes downward motion and the down key causes upward motion.
Here is my code:
function onKeyPress(event:KeyboardEvent):void {
if (event.keyCode==38) {
trace("up arrow pressed");
ball.y+=movement;
}
if (event.keyCode==40) {
trace("down arrow pressed");
ball.y-=movement;
}
I am using a graphic called "ball" here.
Does anybody know why this is happening?
Thanks for reading
y values increase as you move down the stage. You want to reduce the y value to move up, and increase it to move down.
Copy link to clipboard
Copied
y values increase as you move down the stage. You want to reduce the y value to move up, and increase it to move down.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now