6 Replies Latest reply on Apr 17, 2007 1:51 PM by babo_ya

    Probelms with removeChild after addChild works

    csawall
      I am trying to add a component based on the selection of a radio button. I would prefer not to make a state change for this particular change. Almost everything works. All of the resizing works and the addChild() works. However, I get an error when I do a removeChild().

      The error I receive is this:
      Error #2025: The supplied DisplayObject must be a child of the caller.

      This is the function:

      private function function1():void {
      var addDT:datetime = new datetime();
      addDT.x = 58.5;
      addDT.y = 177;
      if(radioA.selected == true) {
      hbox1.y=179;
      hbox2.y=277;
      specialpanel.removeChild(addDT);
      }
      if(radioB.selected == true) {
      hbox1.y=319;
      hbox2.y=417;
      specialpanel.addChild(addDT);
      }
      }

      I don't understand exactly what the error is, if I add it to a panel, why can't I use the same call to remove it?

      Thanks,
      Chris