1 Reply Latest reply on Jul 20, 2007 6:11 AM by Newsgroup_User

    removeChild AS3

    Level 7
      Hi

      I create som MovieClip from My Class on stage! It works!

      public function create_dynamnic_object(){

      for (var i:uint = 1; i <= iAnzahl;i++){
      var cInfoBtn:infobtn = new infobtn();
      cInfoBtn.name = ""+i;
      cInfoBtn.x = 150;
      cInfoBtn.y = i*38;
      TopLevel.stage.addChild(cInfoBtn);
      cInfoBtn.sBez_txt.text = sBez ;
      }
      }

      then i press one of the created MC and a new MC was Addad ! It Works to!

      public function create_dynamic_infofield(sInfotext, sTermine){
      if(obj_exists < 1){
      cInfoText = new ifotxt;
      cInfoText.name = "test1";
      TopLevel.stage.addChild(cInfoText);
      cInfoText.x = 50;
      cInfoText.y = 100;
      cInfoText.ifoTxt.text = sInfotext;
      cInfoText.ifoTermin.text = sTermine;
      obj_exists++;

      var pictLdr1:Loader = new Loader();
      var pictURL1:String = URL_bild;
      //var pictURL:String =
      " http://localhost:81/prj/test/pictures/1hb.jpg";
      var pictURLReq1:URLRequest = new URLRequest(pictURL1);
      pictLdr1.load(pictURLReq1);
      cInfoText.bild.addChild(pictLdr1);;
      }
      }

      in this new MC --> test1 is a button "close"
      this one have to close the "test1"MC!

      public function close_test1(){
      trace("asklöjflakösdjfkl");
      //removeChild(TopLevel.root[cInfoText]);
      cInfoText.removeChild(cInfoText);
      }

      the trace command works!!! but the removeChild says:

      TypeError: Error #2007: Parameter child darf nicht 'null' sein.
      at flash.display::DisplayObjectContainer/removeChild()
      at myClass/close_test1()
      at close/close_Mouse_ev()

      in DEBUG/LIST OBJECT: