Problem duplicating a scrolling mc and removing laser

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:

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:

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.

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;
 }
}
}

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

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

hey man thanks for the help cuse so far no body at all has been able to find a solution and i am not good at all with AS heres the file

http://www.geocities.com/mixedtrigenito/Eros.fla

http://www.geocities.com/mixedtrigenito/Eros.fla

Sorry - been a really busy week and haven’t had a chance to look at it yet. If you can hang on until next week, I’ll have a look then unless someone else can help you in the meantime. Couple of points from quickly looking at it though:
(1) you can only use removeMovieClip(); if the clip was created using duplicateMovieClip. I can’t remember from the file, but I don’t think this was how you created it … Instead, as part of the hit test A/S, simply reset the _x and _y of the laser and make it invisible after it hits an enemy, e.g.
this._x = _root.spaceship._x-15;
this._y = _root.spaceship._y+31;
this._visible = false;

(2)With respect to respawning the ground, I had a brief look at the file and I don’t understand why you are doing it the way you’ve chosen. You could simply make the clip._x the original value once it has gone off the edge of the screen? Search the threads for ‘continuous scrolling’ as there’s plenty here already. My only word of warning is that you’ll need to check the registration point of the star clip (as this is the _x value used) which may not necessarily be what you are expecting it to be in relation to the main stage - especially since it is embedded inside a blank movieclip, so the _x actually refers to it’s position inside that clip, not the _x in relation to the _root. Hope that makes sense!
Tell me how you get on, and as I said, I can always have a better look next week.

t

Ok, I’ve done some fixes… I don’t doubt there is still many other ways to improve it, but that’s the fun for you.:slight_smile:

[try either of these, rar is smaller]

http://hosting.mixcat.com/dinnerdog/Eros_DD.rar
http://hosting.mixcat.com/dinnerdog/Eros_DD.zip

any problems just reply.
good luck

wow man thanks a lot for everything i really appreciated it. and by the way what do you think about the game? even though is not much cuse is my first game with flash. and i just wanted to take it for a test drive.