1 Reply Latest reply on Jun 7, 2007 12:01 PM by kglad

    removeChild does not free up memory completely

    PaulFerreira
      I am dynamically loading images into a movieclip using the funciton below. When the movieclip containint the image is completed tweening, I want to remove it so the memory is freed up. It seems that when I use removeChild, the child mc is removed but the memory isn't freed up completely. Tracing the memory indicates that it keeps growing.
      Does anyone have any suggestions?
      Thanks
      Paul

      function mcLoader(xpos:Number, layer:slideShowLayer, urlP:String, depth:Number)
      {
      var ldr:Loader = new Loader();
      var url:String = 'Barcelona/' + urlP + '.jpg';
      var urlReq:URLRequest = new URLRequest(url);
      ldr.load(urlReq);

      var mc:MovieClip = new MovieClip();
      mc.scaleX = layer.scaleAmount;
      mc.scaleY = layer.scaleAmount;
      mc.x = xpos;
      mc.y = layer.startPos;
      mc_img.addChild(mc);

      mc.addChild(ldr);

      mc.filters = [dropShadowFilter];

      var mcTween:Tween = new Tween(mc, "y", Linear.easeNone, mc.y, tweenEndPos, layer.tweenDuration, true);
      mcTween.addEventListener(TweenEvent.MOTION_FINISH,motionEnd);
      }

      function motionEnd(e:Event):void
      {


      i = 0;
      while (i < mc_img.numChildren)
      {
      var mclip = mc_img.getChildAt(i);
      if (mclip.y >= tweenEndPos) {
      mc_img.removeChild(mc_img.getChildAt(i));
      //mclip.filters = null;
      mclip = null
      }
      else
      {
      i++;
      }
      }
      trace(mc_img.numChildren);
      }