Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4126304
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:59:00+00:00 2026-05-20T23:59:00+00:00

package { import flash.display.Sprite; import flash.events.Event; import flash.events.KeyboardEvent; import flash.ui.Keyboard; public class helloworld extends

  • 0
  package {

  import flash.display.Sprite;
  import flash.events.Event;
  import flash.events.KeyboardEvent;
  import flash.ui.Keyboard;

    public class helloworld extends Sprite {

    public static var x:int = 0;
    public static var y:int = 0;

    public function helloworld() {

      graphics.lineStyle(1, 0, 1);
           stage.focus = this;
           stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);   
    }   

      private function onKeyDown(event:KeyboardEvent):void {

   if (event.keyCode == Keyboard.DOWN)
    {
      y++;
      graphics.moveTo(x,y);
          graphics.drawCircle(x, y, 10);
    }

  if (event.keyCode == Keyboard.RIGHT)
    {
      x++;
      graphics.moveTo(x,y);
          graphics.drawCircle(x, y, 10);
    } 

  }
}

The circles that are drawn first also move. How can I stop it from doing that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:59:01+00:00Added an answer on May 20, 2026 at 11:59 pm

    You think you’re using your public static x & y values, but actually you’re using the Sprite’s built in x and y properties which control its location on the stage. When you use y++ and x++ it moves the entire sprite down/right.

    You should either make sure you’re always calling helloworld.x && helloworld.y (bad idea, easy to forget).

    OR

    You should not use variables named x and y. Try: circleX and circleY or something that is more descriptive of what you’re using it for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following two classes: package { import flash.display.Sprite; import flash.events.Event; public class
My actionscript: package { import flash.display.Graphics; import flash.display.Sprite; import flash.events.Event; import spark.core.SpriteVisualElement; public class
package { import mx.controls.LinkButton; import flash.text.TextLineMetrics; public class multiLineLinkButton extends LinkButton { override protected
I have this class ('Scheduler.as'): package { import flash.events.TimerEvent; import flash.utils.Timer; public class Scheduler
If I have a simple class that has a rectangle: package { import flash.display.Sprite;
package test; import java.awt.*; import java.awt.event.*; import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; import javax.swing.*; public class
I'm writing a preloader: package { import flash.display.DisplayObject; import flash.display.Sprite; import flash.text.TextField; import flash.display.LoaderInfo;
This piece of code is from Adobe docs : package { import flash.display.Loader; import
If I import and use a single class from another package, will it include
Here's the class package db; import java.io.File; import java.io.FileInputStream; import java.sql.Connection; import java.sql.DriverManager; import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.