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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:03:23+00:00 2026-06-01T23:03:23+00:00

I have a problem in ActionScript 3 with a project where I am to

  • 0

I have a problem in ActionScript 3 with a project where I am to output a bunch of data in a diagram and as pure text. This is not the problem, though. The problem is that when the user changes the type of data he wants shown. I would then remove the currently shown columns in the diagram, and add new ones. But my code removes ALL columns, so that there is no diagram at all!

I’ve done it all in Flash CS5, and the columns are instances of an object I made (a rectangle) which I just add to the stage. All the instances are added to the container “container.” When I want to remove them, and add new ones I use:

var container = new Sprite(); // The container for my diagram
function emptyContainer() {
if (container.numChildren > 0) {
    container.removeChildAt(0); 
  }
}

Which works.

I have switch statement that adds the different columns based on user-input. The name of the object (the rectangle) is “soyle.” The name of the instances is “stolpe”
(I am norwegian by the way, so that’s the deal with those weird words)

  function fChange(event:Event) {
textToBeReturned = ""; 

  switch (treCbox.selectedItem.label) {
case "Furu":
    for (var a = 1; a < table.length; a++ ){
        textToBeReturned += "I år: " + table[a][0] + " - " + table[a][1] + " millioner trær." + "\n";
        // Diagram
        var stolpe = new soyle;
        stolpe.width = table[a][1];
        stolpe.x = 20;
        stolpe.y = 100 + (a * 30);
        container.addChild(stolpe);

        // Description for the columns
        var textbox = new TextField;
        textbox.text = "År " + table[a][0];
        textbox.x = stolpe.width + 30;
        textbox.y = stolpe.y;
        container.addChild(textbox);
    }
    break;
case "Gran":
    for (var b = 1; b < table.length; b++ ){
        textToBeReturned += "I år: " + table[b][0] + " - " + table[b][2] + " millioner trær." + "\n" ;

        var stolpe = new soyle;
        stolpe.width = table[b][1];
        stolpe.x = 20;
        stolpe.y = 100 + (b * 30);
        container.addChild(stolpe);

        // Description for the columns
        var textbox = new TextField;
        textbox.text = "År " + table[b][0];
        textbox.x = stolpe.width + 30;
        textbox.y = stolpe.y;
        container.addChild(textbox);
    }
    break;
case "Lauvtre":
    for (var c = 1; c < table.length; c++ ){
        textToBeReturned += "I år: " + table[c][0] + " - " + table[c][3] + " millioner trær." + "\n" ;

        var stolpe = new soyle;
        stolpe.width = table[c][1];
        stolpe.x = 20;
        stolpe.y = 100 + (c * 30);
        container.addChild(stolpe);

        // Description for the columns
        var textbox = new TextField;
        textbox.text = "År " + table[c][0];
        textbox.x = stolpe.width + 30;
        textbox.y = stolpe.y;
        container.addChild(textbox);
    }
    break;
}   
txtReturn.text = textToBeReturned; 
};

I wonder where to place my function for removing all children, to remove just those children that were added earlier. To matter where I place the function (at the start of fChange, at the beginning of each case) there is NO diagram shown, either new or old.

There is of course an array with the data, but I do not post it as it is irrelevant.

Thank you for your time, and in advance for your help! 🙂

  • 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-01T23:03:24+00:00Added an answer on June 1, 2026 at 11:03 pm

    Couple of problems here. I assume you want to remove all children from your container MC before adding new children inside your switch. (Tip for next time, try to post only the code your working with. The switch statement here is large and overwhelming. It’s also not really relevant)

    Your function emptyContainer does not actually remove all children, it only removes one at index 0. This needs to be inside of a loop.

    function emptyContainer() {
       while (container.numChildren > 0) { //changed the if to a while. This will run until there are no children left in container
          container.removeChildAt(0); 
      }
    }
    

    You’re going to want to call this first thing inside of your fChanged function

    function fChange(event:Event) {
         emptyContainer()
    
      /* rest of function */
    
    }
    

    try this out and let me know how it works.

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

Sidebar

Related Questions

I have a pure ActionScript 3 problem, but the simplified test case I've prepared
I have an ActionScript only Flash Builder 4 project of which i know that
I have got a problem with my actionscript class. This is my code: package
I have a Android Actionscript project that I am trying to incorporate sound in,
I have a big loop in actionscript that sends lots of data to an
I have problem with fancybox. I want to write a function that will run
i have problem to correctly bind data to WPF Chart. When i'm setting ItemsSource
i have problem with libhid . i found that there 2 way 4 accessing
I'm using the following code to load an swf in a pure actionscript project
I have this problem when I try to getDefinitionByName('some_var_by_class_linkage') . But I have such

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.