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 6975461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:22:15+00:00 2026-05-27T17:22:15+00:00

I have a basic game function that drops a ball every 500 milliseconds (with

  • 0

I have a basic game function that drops a ball every 500 milliseconds (with a timer event) and suppose to get rid of it when it hits a plate that drags after the mouse. The thing is; I tried to use the deleteChild(); function, but it only removes the visual appearance of the ball object’ without stopping its functionality, which causes a couple of problems:

  1. The ball keeps going, and triggers an event of hitting the floor.
  2. The dropBall(); function which animates the dropping ball, doesn’t actually animate a new ball.

this is the complete script:

//imports:
import flash.events.Event;
import fl.transitions.Tween;
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.TimerEvent;

//the function 'startGame, handles all basic game functions.
function startGame() {

//inisializes the variable 'Score' and gives it a value of 0.
var Score = 0;


//enter_frame listener. calls 'movePlate'
stage.addEventListener(Event.ENTER_FRAME, movePlate);


//function 'movePlate'. makes the plate follow the mouse
function movePlate(event:Event):void {
    plate.x = mouseX;
}


//calls the dropBall function
dropBall()


//the function 'dropBall'. animates the droping ball
function dropBall() {
    var oldpost = 0;
    var randomNum:Number = Math.random() * 550;
    var xAxis:int = Math.round(randomNum);
    trace(randomNum);
    trace(xAxis);
    ball.x = xAxis;
    base.x = xAxis;
    var oldpost = xAxis;
    var ballTween:Tween = new Tween(ball, "y", null, 0, 500, 1.2, true); 
    oldpost = xAxis;
}

//function 'gameTime'. the timer function that controlls the intervals between falling eggs and ratio of good to bad eggs.
var gameTime1:Timer = new Timer(1000);
gameTime1.addEventListener(TimerEvent.TIMER, gameTimer1Function)

function gameTimer1Function(evt:TimerEvent):void {
    dropBall();
}

gameTime1.start();

//enter frame event listener. calls  'checkCollision'
addEventListener(Event.ENTER_FRAME,checkCollision);


//function checl collision. checks if the ball hits the plate
function checkCollision(event: Event):void {
    if(ball.hitTestObject(plate)) collisionDetected();
}


//function collision detected
function collisionDetected():void {
    Score ++;
    trace(Score);
    scoreText.text = Score;

}


//enter frame event listener. calls  'checkGameOver'.
addEventListener(Event.ENTER_FRAME,checkGameOver);
 //function 'checkGameOver.
function checkGameOver(event: Event):void {
    if(ball.hitTestObject(floor)) gameOver();
}


//function 'gameOver'.
function gameOver():void {
    trace('GAME OVER!!! Your Score Is: ' + Score + '.');
    trace('Asta la Vista Baby :D');

}
}
startGame();
  • 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-27T17:22:16+00:00Added an answer on May 27, 2026 at 5:22 pm

    Your’e code is not working as you explained. It is working like this:

    You have only one ball, and it is beeing thorwn up, every second, refering to gameTime1 tick calls dropBall (), which doing the following:

    • it replaces the single ball you have to the 0 possition, and animating it withhin 1.2 seconds to the bottom. var ballTween:Tween = new Tween(ball, "y", null, 0, 500, 1.2, true);
    • then the score++ is triggered independantly from the ball movement because it is on the enterframe event handler, and each frame the ball is hitting the plate the score increases
    • YOU SHOULD REALLY LOOK INTO YOUR CODE AGAIN, and rething the architecture, how what and when it should work ( basicaly not only you need to know, what the software should do, but you need to explain this to the software.

    UPDATE:

    For how to export the movieclipt int oclass follow the tutorial:
    http://www.kirupa.com/developer/flashcs3/movieclips_classes_AS3_pg1.htm

    Then in your logics:

    Function ( createBall )

    • Create a instance of the ball. ( if you followed tutorial then you know how to )
    • start the enterFrame which checks if the ball hitted the panel or the ground if it did stop the enterFrame event.
    • After stop deside what to do depending on what was hitted

    Should look like this:

    if ( hitPanel )
    {
        increaseScrore ()
    }
    if ( hitFloor )
    {
        decreaseLive () 
    }
    
    • in each of those functions increase... and decrease.. after they done everything should be removeBall function, and in increase.. then a call to the createBall so everything is starting to repeat.

    P.S. No offence please, but you can learn the programming language, in this case i see you know a bit, but if you are missing some logics, you will not find it on forums… Read some basics info about logics / architectures of the applications etc… and please take a look how the instances needed to be handeled.

    P.S.S. Invest some to to know wtf is OOP. 😉

    best wishes! Happy holidays 🙂

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

Sidebar

Related Questions

I have an image of a basic game map. Think of it as just
I am making a basic platform game for the iPhone and I have encountered
My current class is planning on creating a basic networked game, but we have
I have a pretty basic challenge-based iPhone game, and I wanted to know what
I have a basic form with controls that are databound to an object implementing
I have a basic CRUD form that uses PageMethods to update the user details,
I have coded a basic game in JavaScript and am working on a high
I have a trivial little game I wrote in javascript that creates a wave
If I have some basic game loop in a thread, like this: public void
I am building a game in Visual Basic called Battleship. I have 100 buttons

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.