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

The Archive Base Latest Questions

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

I have a container with children that needs to be replaced by other periodically.

  • 0

I have a container with children that needs to be replaced by other periodically. Those children are sprites and they have one weak referenced event listeners for MOUSE_DOWN event. When I call removeChild on children, numChildren from container decreases to 0 but they are still visible in flash. I even tried to remove container and recreate new one but it still doesn’t work. Also tried to add some dummy simple sprite instead, without any event listeners but it didn’t bring any results. I presume that garbage collector is not working as I wish 🙂

Here is my code for creating sprites:

itemHolder=new Sprite();
addChild(itemHolder);
itemHolder.y=itemHolderY;

var itemY:Number=0;

for(var i:Number=0;i<modelBarList.bars.length;i++){
    var item:bar_list_item;
    item=new bar_list_item();
    item.name="item"+i;
    /*
    setting properties for item
    */
    itemHolder.addChild(item);              
    item.y=itemY;
    item.mouseChildren=false;
    item.buttonMode=true;
    itemY+=item.height;
    item.addEventListener(MouseEvent.MOUSE_UP,barSelected,false,10,true);
}

And code for removing:

while(itemHolder.numChildren){
    var item:Sprite=Sprite(itemHolder.getChildAt(0));
    item.removeEventListener(MouseEvent.MOUSE_UP,barSelected,false);
    itemHolder.removeChild(item);
    item=null;
}
removeChild(itemHolder);
itemHolder=null;
  • 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-20T05:59:28+00:00Added an answer on May 20, 2026 at 5:59 am

    I don’t think it has anything to do with Garbage Collector. Are you 100% sure that the itemHolder in second code is the same as the itemHolder in the first? Perhaps you could try adding trace("Yep, this code executes") to the second snippet and see if it executes for sure? That, or the problem lies somewhere else in your code I think.

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

Sidebar

Related Questions

I have an event handler that triggers an event handler that needs to test
I have a top level container (JFrame) that contains two JPanels. One of the
I have a container that is a popup over a page and it has
I have a container that is used to show a breadcrumb path through a
I have a container that contains an image that I need to drag from
I have a menu with a 'Windows' list that contains all mdi children thanks
I have a package that will be inserting a single parent record in one
I'm building a game project where there are simple container objects that can have
I have an element that looks something like this. <xsd:element name=container> <xsd:complexType> <xsd:choice minOccurs=0
I have a JAX-RPC (Java) web service that needs to return a complex polymorphic

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.