3 Replies Latest reply on Sep 2, 2010 6:09 AM by Gregory Lafrance

    Problem adding elements to a group after removing everything...

    JoeRocket1148 Level 1

      Hi everyone,


      I would really appreciate some help on something. I have a Group that has some Buttons in it. This Group is in one of fours States, and there is a componant for each State. After the user goes through the rest of the program and comes back to this State, I want to remove the old buttons, and add new buttons with new values. Bascially, I want to refresh the componant when it is visited a second time. I have a problem adding new Buttons to the group when the user revisits the componant / state.


      The group is created:

                <s:VGroup id="buttons"  x="0" y="35"  height="400" width="280" />


      When the init function for that componant is called, buttons are added from an array of buttons:

      for(var i:int = 0; i < 10; i++){
                var button:Button = questions[i];
                button.addEventListener(MouseEvent.CLICK, myEventHandler);


      When the user moves on to the next State, the buttons are removed:

      if(counter == 4){
                FlexGlobals.topLevelApplication.currentState = 'Summary';


      When the user comes back to the initial state, the buttons are not added to the Group like they are the first time. The output of the trace as each button is added is also different the second time:


      First time: (successful)



      Second time:




      Can anyone point me in the right direction? And better question, is there a better way I should be doing this?


      Is there a better way to refresh everything within a component upon viewing it s second time?



      Thanks in advance!