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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:14:37+00:00 2026-05-27T05:14:37+00:00

I am creating a game in which bubbles with simple math equations are falling

  • 0

I am creating a game in which bubbles with simple math equations are falling from the top of the screen, and you have to enter in the answer to make the specific bubble disappear. The only problem is that I need a system that can delete the bubble(s) corresponding to the answer. I’m using an Actions-Frame code and a mathBubble AS class. I will show the frame code first.

stop();
var cooldown:int = 200;
var cooldownMax:int = 200;
inputAnswer.restrict = "^A-Za-z";
addEventListener(Event.ENTER_FRAME, bubbleSpawn);

function bubbleSpawn(e:Event) {

    if (cooldown>cooldownMax) {
        var bubble = new mathBubble();
        addChild(bubble);
        bubble.x = Math.round(Math.random()*480);
        bubble.y = 0;
        cooldown = 0;
    }

    cooldown += 1;

}

package {

    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.text.*;

    public class mathBubble extends MovieClip {

        var firstInteger:int;
        var equationSymbol:int;
        var secondInteger:int;
        var mathAnswer:int;
        var firstSpace:String;
        var secondSpace:String;
        var mathAnswerString:String;

        function mathBubble() {
            firstInteger = Math.round(Math.random()*9);
            equationSymbol = Math.round(Math.random()*2)+1;
            secondInteger = Math.round(Math.random()*9);

            trace("bubble spawned");

            firstSpace = String(firstInteger);
            secondSpace = String(secondInteger);
            firstNumber.text = firstSpace;
            secondNumber.text = secondSpace;

            if (equationSymbol==1) {
                mathSymbol.text = "+";
                mathAnswer = firstInteger+secondInteger;
                mathAnswerString = String(mathAnswer);
                trace(mathAnswerString);
            }
            if (equationSymbol==2) {
                mathSymbol.text = "-";
                mathAnswer = firstInteger-secondInteger;
                mathAnswerString = String(mathAnswer);
                trace(mathAnswerString);
            }

            if (equationSymbol==3) {
                mathSymbol.text = "x";
                mathAnswer = firstInteger*secondInteger;
                mathAnswerString = String(mathAnswer);
                trace(mathAnswerString);
            }

            addEventListener(Event.ENTER_FRAME, bubbleFall);
            function bubbleFall(e:Event) {
                y += 1;
            }
        }
    }
}

Reading the code is not completely necessary, I was just wondering if anybody could explain how I could use arrays to remove every child with the same answer as the randomized answer each child contains through variables “mathAnswer” and “mathAnswerString”
I figured arrays would be how this would work, but if there’s any other way then please say so. Thank you for reading this far.

  • 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-27T05:14:38+00:00Added an answer on May 27, 2026 at 5:14 am

    You could use a CustomEvent with the an answer property. After an answer is given dispatch an event with the answer, each bubble can then check against their own answer.

    If the strings are identical, you will need to implement a remove function in the bubble, where you remove all event listeners and finally the parent remove the child.

    To dispatch and listen to the event you could pass an event dispatcher as a parameter to each bubble.

    For a child to remove itself:

        if(this.parent != null )
           this.parent.removeChild( this );
    

    As for the child removing itself after its y position is greater than 50, I’m not sure having the child removing itself would be the better solution since you would have to implement an enter frame event listener in each bubble… it may be more efficient to have a single event listener in the container checking all bubbles.

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

Sidebar

Related Questions

i am creating a game which has a HUD layer on top showing scores
I am creating a program which launches a game server. I have combobox in
I am creating a game which have similar concept like Tap Tap Ant .
I am creating a game in which I have a menu with multiple views
I have am creating a game.Then game has a timer 100 sec ,which move
I'm creating a simple game using HTML and CSS. I have a background image
I am creating game which involves some billiard-like balls to bounce on the screen.
I'm creating a game in which I have a somewhat complex method for creating
I am creating a simple game which after a 5 second timer expires and
I'm writing a simple game. I have 3 classes the first one: ball which

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.