2 Replies Latest reply on Sep 17, 2007 2:00 AM by lokalhorst

    removeChild problem...

    lokalhorst
      please have a look at the following code:

      var n:int = 0;
      function setDotz():void
      {
      var dot = new point();
      var intstanceName:String = "p_mc"+n;
      dot.name = intstanceName;
      this.container_mc.addChild(dot);

      /*var target:DisplayObject = this.container_mc.getChildByName(intstanceName);
      trace(target.name);
      this.container_mc.removeChild(target);

      Here it works.
      */
      n++;
      }

      function removeDotz(i:int)
      {
      var intstanceName:String = "p_mc"+i;
      var target:DisplayObject = this.container_mc.getChildByName(intstanceName);
      trace(target.name);
      this.container_mc.removeChild(target);

      /*Here it does not work. Although the trace(target.name) gives the correct result,
      this.container_mc.removeChild(target) fails with the Error #1009:
      Cannot access a property or method of a null object reference.*/

      }

      for (var k:int = 0; k <=20; k++)
      {
      setDotz();
      if (n >=20)
      {
      for (var i:int = 0; i <=20; i++)
      {
      removeDotz(i);
      }
      }
      }

      I have no idea why i receive an Error #1009: Cannot access a property or method of a null object reference when
      when this line "this.container_mc.removeChild(target)" in the removeDotz is executed.

      Can anyone help please.
        • 1. Re: removeChild problem...
          kglad Adobe Community Professional & MVP
          with those typos your code wouldn't work, at all.

          copy your relevant code and use the attach code option to paste your code to this forum.
          • 2. Re: removeChild problem...
            lokalhorst Level 1
            O.k. I attached the code.So please, if anyone has an idea...

            kglad:
            this my 2 (second) thread in this forum. In my first thread, the first reply was given by you with the wrong suggestion, my code is faulty and 'poorly' written.
            You are going to repeat the same nonsense here again. In fact there are no 'typos' in that code. Just copy and paste and you could find out yourself. This would cost you less time than writing your 26137 th post.
            I don't want to flame anyone or impute anything. I just need some relevant advices without getting some personal inked comments by some double platinum power posters. Therefore i encourage you to stop posting to my threads like this! Thanks.

            So i hope that forum is the right place to be...