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

The Archive Base Latest Questions

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

i don’t understand why none of my display objects are not being removed. when

  • 0

i don’t understand why none of my display objects are not being removed. when i press the button, i’m expecting a trace and removal of both shapes and the button, but nothing happens:

import fl.controls.Button;

var shape1:Shape = new Shape();
shape1.name = "Shape1";
shape1.graphics.lineStyle(4, 0x000000);
shape1.graphics.beginFill(0x000055, 0.5);
shape1.graphics.drawRoundRect(50, 50, 100, 75, 20, 30);
shape1.graphics.endFill();
addChild(shape1);

var shape2:Shape = new Shape();
shape2.name = "Shape2";
shape2.graphics.lineStyle(4, 0xFFFF99);
shape2.graphics.beginFill(0x550000, 0.5);
shape2.graphics.drawRoundRect(100, 75, 200, 175, 50, 10);
shape2.graphics.endFill();
addChild(shape2);

button1.addEventListener(MouseEvent.CLICK, pushButton);
function pushButton(evt:MouseEvent):void
    {
    for(var amount:int = numChildren; amount == 0; amount--)
        {
        trace(amount);
        var disObj:DisplayObject = getChildAt(amount);
        trace("Removing " + disObj.name);
        removeChildAt(amount);
        }
    }

i realize there are better ways of accomplishing this, but i’m learning and therefore only interested in why the above code doesn’t work.

  • 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-14T00:18:38+00:00Added an answer on May 14, 2026 at 12:18 am

    Change your for loop to: for(var amount:int = numChildren - 1; amount >= 0; amount--)

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

Sidebar

Related Questions

I don't understand why my output is not how I think it should be.
Don't understand why #include <Header.h> is not compiling while #include Header.h is compiling with
I don't understand where the extra bits are coming from in this article about
I don't want PHP errors to display /html, but I want them to display
I don’t think I’ve grokked currying yet. I understand what it does, and how
I don't remember whether I was dreaming or not but I seem to recall
Don't want to sort the entries. using this does not preserve the order as
I don't know if this is possible. I display a table of results and
This is beyond both making sense and my control. That being said here is
Don't worry, I'm not going to ask that question, yet again... I am wanting

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.