Skip to main content
Known Participant
July 10, 2013
Answered

I can addChild movieClip using check box, but how do you removeChild when box is unchecked?

  • July 10, 2013
  • 1 reply
  • 1671 views

I will have 8 check boxes on this screen. I want the user to check any number or all boxes to see a line on a graph. I also want them to be able to uncheck the selected box to remove the line. Each box calls a certain line to the stage.

I can get the line to show up when checked, but not dissappear when unchecked.

I also want to have a check box to select all lines on the screen.

var graph:hp455mt_mc = new hp455mt_mc();

box455.addEventListener(MouseEvent.CLICK, clickHandler);

function clickHandler(evt:MouseEvent):void {

  addChild(graph);
graph.x = 179;
graph.y = 22.35;     
}

This topic has been closed for replies.
Correct answer Ned Murphy

You can use the same function and within it have a conditional to check if the box selected property is true... if it is then you add the child and if it is false you remove the child.

....

   if(box455.selected){

        addChild(etc...

   } else {

        removeChild(etc....

   }

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
July 10, 2013

You can use the same function and within it have a conditional to check if the box selected property is true... if it is then you add the child and if it is false you remove the child.

....

   if(box455.selected){

        addChild(etc...

   } else {

        removeChild(etc....

   }

Known Participant
July 10, 2013

Thanks! This is a great help.

Ned Murphy
Legend
July 12, 2013

Very cool! Thanks!


You're welcome