2 Replies Latest reply on Mar 16, 2010 8:07 AM by PDL_AGH

    how to copy and duplicate a container inside another container?

    PDL_AGH

      Hello,

       

      I'm trying to copy and duplicate a container inside another container. At the momment, I try to do this with a HBox and all its children displayObject inside a VBox.

       

      When I build the different displayObject  in one HBox, at the end of the line, I add a button with the following addEventListener:

       

      newButton.addEventListener(MouseEvent.CLICK, addNewLineButton);

       


      Further in the code I have this function:


              private function addNewLineButton(event:MouseEvent):void{
                  event.target.parent.parent.addChild(event.target.parent);
              }

       

      Where the target is said Button, its parent said HBox and the parent of the parent said VBox. I know this function is called and yet it doesn't have any effect.

       

      Could anybody please explain me why this does not have any effect? Or alternatively another way to  copy and duplicate a container inside another container?

       

      All the best,

      Pierre