# attachMovieClip(); problem - lag

**URL:** <https://forum.kirupa.com/t/attachmovieclip-problem-lag/224288>\
**Category:** flash\
**Created:** [April 30, 2007, 11:16pm UTC](https://forum.kirupa.com/t/attachmovieclip-problem-lag/224288 "2007-04-30T23:16:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skimmmer](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@skimmmer](https://forum.kirupa.com/u/skimmmer)\
**Post date:** [April 30, 2007, 11:16pm UTC](https://forum.kirupa.com/t/attachmovieclip-problem-lag/224288/1 "2007-04-30T23:16:03Z")

</div>

I’m making a game that makes lines after a moving object. First I used the dulpicateMovieClip(); function but that made it lag. So then I modified the script to attachMovieClip(); this still makes it lag after awhile. None of the movie clips I am duplicating have script in them. Also after awhile I use the unloadMovieClip(); function but it still lags. I have also used the removeMovieClip(); function

Here is some of the script:

```auto

if (mySpeed>.5) {
   _root.trail1.createEmptyMovieClip("1trail"+i, count);
   _root.trail1["1trail"+i].lineStyle(10, 0x0099FF, 20);
   _root.trail1["1trail"+i].moveTo(car._x, car._y);
   _root.trail1["1trail"+i].lineTo(newcarX, newcarY);
   count += 1;
   i++;
   _root.trail1array[_root.trail1arraySize] = i;
   _root.trail1arraySize++;
   updateAfterEvent();
  }

```

and

```auto

for (l=0; l<_root.lazerarraySize; l++) {
   if (_root.wall1.hitTest(_root["bluelaz"+_root.lazerarray[l]]._x, _root["bluelaz"+_root.lazerarray[l]]._y, true)) {
    _root["bluelaz"+_root.lazerarray[l]].play();
   } else {
    _root["bluelaz"+_root.lazerarray[l]]._x += Math.cos(Math.PI/180*(90-_root["bluelaz"+_root.lazerarray[l]]._rotation))*8;
    _root["bluelaz"+_root.lazerarray[l]]._y += -Math.sin(Math.PI/180*(90-_root["bluelaz"+_root.lazerarray[l]]._rotation))*8;
   }
  }

```

Note: in the one above blueLaz.play(); plays the movieclip and the at the end removes it.

Thanks for any help.
