# Problem duplicating a scrolling mc and removing laser

**URL:** <https://forum.kirupa.com/t/problem-duplicating-a-scrolling-mc-and-removing-laser/114835>\
**Category:** Uncategorized\
**Created:** [July 2, 2004, 6:00am UTC](https://forum.kirupa.com/t/problem-duplicating-a-scrolling-mc-and-removing-laser/114835 "2004-07-02T06:00:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mixedtrigeno](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@mixedtrigeno](https://forum.kirupa.com/u/mixedtrigeno)\
**Post date:** [July 2, 2004, 6:00am UTC](https://forum.kirupa.com/t/problem-duplicating-a-scrolling-mc-and-removing-laser/114835/1 "2004-07-02T06:00:11Z")

</div>

im almost done with my game but i have two problems.

1. when the laser hits and enemy it doesn’t disappear instead it keeps going through enemies until its out of the screen.  
-i tried to add a removemovieclip to it but when i did it it removed the laser that you cant even shot no more.hehe

2)when i move forward the stars scroll fine but when that one reaches the end of the end the other stars that is suppose to be respawn .respawns at the same spot i had the other one previously. i dont know if i am explaining this the right way.

this is the code on the on the spaceship:

```auto
onClipEvent (load) {
 moveSpeed = 15;
 _root.laser._visible = false;
 laserCounter = 1;
 _root.missile._visible = false;
 missileCounter = 1;
 scrollx = _root.mainGround.ground._width/3;
 scrollStart = false;
 maxLasers = 4;
 maxMissile = 1;
 depthCounter = 1;
 depthCounters = 10;
 enemie **** = 0;
}
onClipEvent (enterFrame) {
 if (Key.isDown(Key.SPACE) and (laserCounter<=maxLasers)) {
  laserCounter++;
  _root.laser.duplicateMovieClip("laser"+depthCounter, depthCounter);
  _root["laser"+depthCounter]._visible = true;
  depthCounter++;
  if (depthCounter>maxLasers) {
   depthCounter = 1;
  }
 }
 if (Key.isDown(Key.CONTROL) and (missileCounter<=maxMissile)) {
  missileCounter++;
  _root.missile.duplicateMovieClip("missile"+depthCounters, depthCounters);
  _root["missile"+depthCounters]._visible = true;
  depthCounters++;
  if (depthCounters>maxMissile) {
   depthCounters = 10;
  }
 }
 if (Key.isDown(Key.RIGHT)) {
  if (this._x<scrollx) {
   this._x += moveSpeed;
  } else {
   scrollStart = true;
  }
 } else if (Key.isDown(Key.LEFT) and this._x>30) {
  this._x -= moveSpeed;
 }
 if (Key.isDown(Key.DOWN) and this._y<280) {
  this._y += moveSpeed;
 } else if (Key.isDown(Key.UP) and this._y>15) {
  this._y -= moveSpeed;
 }
}
onClipEvent (keyUp) {
 if (Key.getCode() == Key.RIGHT) {
  scrollStart = false;
 }
}

```

this is the code on the laser:

```auto
onClipEvent (load) {
 laserMoveSpeed = 20;
 this._x = _root.spaceship._x-15;
 this._y = _root.spaceship._y+31;
}
onClipEvent (enterFrame) {
 if (this._name<>"laser") {
  this._x += laserMoveSpeed;
  if (this._x>750) {
   _root.spaceship.laserCounter--;
   this.removeMovieClip();
  }
  for (i=1; i<=_root.numEnemy; i++) {
   if (this.hitTest(_root["enemy"+i]) and _root["enemy"+i].hitFlag == false) {
    _root.score += 100;
    _root.spaceship.enemie **** ++;
    if (_root.spaceship.enemie **** >=20) {
     _root.spaceship.enemie **** = 0;
     _root.newLevel();
    }
    _root["enemy"+i].hitFlag = true;
    _root["enemy"+i].gotoAndPlay(2);
   }
  }
 }
}

```

this is the code on the star:  
NOTE: the movie is 700x350 resolution running at 20fps.

```auto
onClipEvent (load) {
ground.duplicateMovieClip("ground2", 100);
ground2._x = ground._x+ground._width;
groundStartx = this._x;
groundSpeed=15;
}
onClipEvent (enterFrame) {
if (_root.spaceship.scrollStart){
 this._x-=groundSpeed;
 if (this._x<= (groundStartx-ground._width)){
  this._x=groundStartx-groundSpeed;
 }
}
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 5, 2004, 7:45am UTC](https://forum.kirupa.com/t/problem-duplicating-a-scrolling-mc-and-removing-laser/114835/2 "2004-07-05T07:45:02Z")

</div>

can anyone please help me out if u need the fla let me know anyone

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 5, 2004, 8:30am UTC](https://forum.kirupa.com/t/problem-duplicating-a-scrolling-mc-and-removing-laser/114835/3 "2004-07-05T08:30:20Z")

</div>

post the fla and I’ll have a look :¬)
