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

  • SEARCH
  • Home
  • 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 7853747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:47:24+00:00 2026-06-02T19:47:24+00:00

So I have been making this game with Action Script 3, and CS5.5. What

  • 0

So I have been making this game with Action Script 3, and CS5.5. What you are trying to do is avoid asteroids while you fly through space. I thought it would be cool to have the planets in out solar system be moving down the screen throughout the game in the background. Kinda to make it look like you were flying pass them. The way I did this was I added five to their y coordinate each frame per second. Once their y coordinate reached 600 ( the bottom of the screen ) I would add a new planet which would do the same thing. For some reason once I got to Saturn everything got weird. Saturn came to early, and so did Uranus. I had no idea what was going on. I have been frustrated with this for a good hour. Here is the part where I think there is the problem.

public function onTick(timerEvent:TimerEvent):void
{

        earth.PlanetMovement(5);

        if (earth.y==600)
        {
            mars.PlanetsStart(300, -100);
            addChild( mars );
            levels=levels+5;
        }
        mars.PlanetMovement(5);
        if (mars.y==600)
        {
            jupiter.PlanetsStart(300,-150);
            addChild (jupiter);
            levels=levels+10;
        }
        jupiter.PlanetMovement(5);

        if (jupiter.y==600)
        {
            saturn.PlanetsStart(300,-155);
            addChild (saturn);
            levels=levels+20;
        }
        saturn.PlanetMovement(5);
        if (saturn.y==600)
        {
            uranus.PlanetsStart(300,-160)
            addChild ( uranus);
            levels=levels+25;
        }
        uranus.PlanetMovement(5);

PlanetMovement, and PlanetsStart are two functions in the Planets class. If you need more info please tell me.

EDIT: I guess I should explain further. PlanetsStart is a function that has the starting coordinate of each movieclip. So once earth reached a y coordinate of 600, then mars starts at (300, -100). Then it is added to the screen. levels is a variable that raises the score each fps. PlanetMovement is how much each movieclip will move each fps. If I were to use >= then the score would raise too much.

This is exactly what happens. earth shows up where it is supposed to. Then mars showd up on time. Then for some reason Saturn pops up in the middle of mars, and Jupiter. After this Saturn reaches the bottom making Uranus appear. Then Jupiter reaches the bottom, and everything works as it should. Saturn shows up, and then Uranus in order

  • 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-06-02T19:47:26+00:00Added an answer on June 2, 2026 at 7:47 pm

    Ugh. Unfortunately, this is more complex than you are implying. It would really help you to write a code plan of some sort first, develop some psuedo-code that will show basic logic (and the logic errors), and then code after that.

    Below is an example of a better way to structure this idea. However, I don’t think your idea is terrible memory conscious. You should only bring in the planets as needed, and remove them as needed as well. Look into a technique called “object pooling” to help better structure this.

    Solar system class:

    package  
    {
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.geom.Point;
    
        public class SolarSystem extends MovieClip 
        {
            private var PLANET_NAMES:Array = new Array("earth", "mars", "jupiter", "saturn", "uranus");
    
            // you will have to fix these values:
            private var PLANET_STARTS:Array = new Array(new Point(300, -100), new Point(300, -100),new Point(300, -100),new Point(300, -100),new Point(300, -100));
    
            private var planets:Array;
            private var maxY:Number = 600;
            private var speed:Number = 5;
    
            private var levels:Number = 0;
            private var levelIncrement:Number = 5;
    
            public function SolarSystem() 
            {
                super();
                addEventListener(Event.ADDED_TO_STAGE, initHnd, false, 0, true);
            }
    
            private function initHnd(e:Event):void 
            {
                removeEventListener(Event.ADDED_TO_STAGE, initHnd);
    
                runPlanets();
    
                addEventListener(Event.ENTER_FRAME, frameHnd, false, 0, true);
            }
    
            private function runPlanets():void 
            {
                for (var i:int = 0; i < PLANET_NAMES.length; i++) 
                {
                    planets[i] = new Planet();
                    planets[i].name = PLANET_NAMES[i];
                    Planet(planets[i]).startPlanet(PLANET_STARTS[i]);
                    this.addChild(planets[i]);
                }
            }
    
            private function frameHnd(e:Event):void 
            {
                if(planets && planets.length > 0){
                    // move all the planets until they are too low, then remove them.
                    // decrementing loop because planets will be being removed occasionally.
                    for (var i:int = planets.length -1; i >= 0; i--) 
                    {
                        if (planets[i] && Planet(planets[i]).y >= maxY) {
    
                            // this seems very strange to me, but it will replicate what your code says:
                            levels += (levels + levelIncrement);
    
                            try {
                                removeChild(Planet(planets[i]));
                                planets[i] = null;
                            }catch (e:Error) { }
                        } else if ( Planet(planets[i]).isMoving ){
                            Planet(planets[i]).movePlanet(0, speed);
                        }
                    }
                } else {
                    removeEventListener(Event.ENTER_FRAME, frameHnd);
                }
            }
        }
    }
    

    and here is the planet class:

    package
    {
        import flash.display.MovieClip;
    
        public class Planet extends MovieClip
        {
            private var _isMoving:Boolean = false;
    
            public function Planet()
            {
                super();
            }
    
            public function startPlanet(sx:Number, sy:Object):void
            {
                this.x = sx;
                this.y = sy;
    
                isMoving = true;
            }
    
            public function movePlanet(dx:Number, dy:Number):void
            {
                if (isMoving)
                {
                    this.x += dx;
                    this.y += dy;
                }
            }
    
            public function get isMoving():Boolean
            {
                return _isMoving;
            }
    
            public function set isMoving(value:Boolean):void
            {
                _isMoving = value;
            }
        }
    }
    

    Again, this is not the best way to do this, but it is more manageable to group concepts and actions into classes.

    HTH.

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

Sidebar

Related Questions

I have been trying to draw multiple balls for a game I am making,
I am making a game that needs a crosshair. I have been playing with
I am making a simple 2d game in the terminal, and I have been
I am making a 2d space game with many moving objects. I have already
So, basically, I've been writing this Game of Life PHP script. My output is
I'm making the memory game concentration. In this I have a specified obligation to
I have been making some research in the domain of servers for a website
For some time i have been making more or less little games. One level
I have been using the Rails console a fair bit lately and its making
Have been working on this question for a couple hours and have come close

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.