Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Up (keyCode 38) and Down (keyCode 40) Keys Reversed?

New Here ,
Feb 08, 2014 Feb 08, 2014

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

TOPICS
ActionScript
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 08, 2014 Feb 08, 2014

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.

Translate
LEGEND ,
Feb 08, 2014 Feb 08, 2014
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines