# Problem duplicating a scrolling mc and removing laser

**URL:** <https://forum.kirupa.com/t/problem-duplicating-a-scrolling-mc-and-removing-laser/114834>\
**Category:** Uncategorized\
**Created:** [July 2, 2004, 5:55am UTC](https://forum.kirupa.com/t/problem-duplicating-a-scrolling-mc-and-removing-laser/114834 "2004-07-02T05:55:03Z")\
**Posts on this page:** 1\
**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, 5:55am UTC](https://forum.kirupa.com/t/problem-duplicating-a-scrolling-mc-and-removing-laser/114834/1 "2004-07-02T05:55:03Z")

</div>

[font=verdana, arial, helvetica][size=2]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:

[/size][/font][indent]

[font=verdana,arial,helvetica][size=1]ActionScript:[/size][/font]\<HR\>\<STYLE\>PRE {font : normal normal normal 13 “Courier New”, Courier, Arial;;}\</STYLE\>

[color=#000087]onClipEvent[/color] ([color=#000087]load[/color]) { moveSpeed = 15; [color=#000087]\_root[/color].laser.[color=#000087]\_visible[/color] = [color=#000087]false[/color]; laserCounter = 1; [color=#000087]\_root[/color].missile.[color=#000087]\_visible[/color] = [color=#000087]false[/color]; missileCounter = 1; scrollx = [color=#000087]\_root[/color].mainGround.ground.[color=#000087]\_width[/color]/3; scrollStart = [color=#000087]false[/color]; maxLasers = 4; maxMissile = 1; depthCounter = 1; depthCounters = 10; enemie\*\*\*\* = 0;}[color=#000087]onClipEvent[/color] (enterFrame) { [color=#000087]if[/color] ([color=#000087]Key[/color].[color=#000087]isDown/color [color=#000087]and[/color] (laserCounter\<=maxLasers)) { laserCounter++; [color=#000087]\_root[/color].laser.[color=#000087]duplicateMovieClip[/color]("[color=blue]laser[/color]"+depthCounter, depthCounter); [color=#000087]\_root[/color]["[color=blue]laser[/color]"+depthCounter].[color=#000087]\_visible[/color] = [color=#000087]true[/color]; depthCounter++; [color=#000087]if[/color] (depthCounter\>maxLasers) { depthCounter = 1; } } [color=#000087]if[/color] ([color=#000087]Key[/color].[color=#000087]isDown/color [color=#000087]and[/color] (missileCounter\<=maxMissile)) { missileCounter++; [color=#000087]\_root[/color].missile.[color=#000087]duplicateMovieClip[/color]("[color=blue]missile[/color]"+depthCounters, depthCounters); [color=#000087]\_root[/color]["[color=blue]missile[/color]"+depthCounters].[color=#000087]\_visible[/color] = [color=#000087]true[/color]; depthCounters++; [color=#000087]if[/color] (depthCounters\>maxMissile) { depthCounters = 10; } } [color=#000087]if[/color] ([color=#000087]Key[/color].[color=#000087]isDown/color) { [color=#000087]if[/color] ([color=#000087]this[/color].[color=#000087]\_x[/color]\<scrollx) { [color=#000087]this[/color].[color=#000087]\_x[/color] += moveSpeed; } [color=#000087]else[/color] { scrollStart = [color=#000087]true[/color]; } } [color=#000087]else[/color] [color=#000087]if[/color] ([color=#000087]Key[/color].[color=#000087]isDown/color [color=#000087]and[/color] [color=#000087]this[/color].[color=#000087]\_x[/color]\>30) { [color=#000087]this[/color].[color=#000087]\_x[/color] -= moveSpeed; } [color=#000087]if[/color] ([color=#000087]Key[/color].[color=#000087]isDown/color [color=#000087]and[/color] [color=#000087]this[/color].[color=#000087]\_y[/color]\<280) { [color=#000087]this[/color].[color=#000087]\_y[/color] += moveSpeed; } [color=#000087]else[/color] [color=#000087]if[/color] ([color=#000087]Key[/color].[color=#000087]isDown/color [color=#000087]and[/color] [color=#000087]this[/color].[color=#000087]\_y[/color]\>15) { [color=#000087]this[/color].[color=#000087]\_y[/color] -= moveSpeed; }}[color=#000087]onClipEvent[/color] (keyUp) { [color=#000087]if[/color] ([color=#000087]Key[/color].[color=#000087]getCode/color == [color=#000087]Key[/color].[color=#000087]RIGHT[/color]) { scrollStart = [color=#000087]false[/color]; }}\</PRE\>\<HR\>\</PRE\>[/indent][font=verdana, arial, helvetica][size=2]

this is the code on the laser:

[/size][/font]

[indent]

[font=verdana,arial,helvetica][size=1]ActionScript:[/size][/font]\<HR\>\<STYLE\>PRE {font : normal normal normal 13 “Courier New”, Courier, Arial;;}\</STYLE\>

[color=#000087]onClipEvent[/color] ([color=#000087]load[/color]) { laserMoveSpeed = 20; [color=#000087]this[/color].[color=#000087]\_x[/color] = [color=#000087]\_root[/color].spaceship.[color=#000087]\_x[/color]-15; [color=#000087]this[/color].[color=#000087]\_y[/color] = [color=#000087]\_root[/color].spaceship.[color=#000087]\_y[/color]+31;}[color=#000087]onClipEvent[/color] (enterFrame) { [color=#000087]if[/color] ([color=#000087]this[/color].[color=#000087]\_name[/color]\<\>"[color=blue]laser[/color]") { [color=#000087]this[/color].[color=#000087]\_x[/color] += laserMoveSpeed; [color=#000087]if[/color] ([color=#000087]this[/color].[color=#000087]\_x[/color]\>750) { [color=#000087]\_root[/color].spaceship.laserCounter–; [color=#000087]this[/color].[color=#000087]removeMovieClip/color; } [color=#000087]for[/color] (i=1; i\<=[color=#000087]\_root[/color].numEnemy; i++) { [color=#000087]if[/color] ([color=#000087]this[/color].[color=#000087]hitTest/color [color=#000087]and[/color] [color=#000087]\_root[/color]["[color=blue]enemy[/color]"+i].hitFlag == [color=#000087]false[/color]) { [color=#000087]\_root[/color].score += 100; [color=#000087]\_root[/color].spaceship.enemie\*\*\*\*++; [color=#000087]if[/color] ([color=#000087]\_root[/color].spaceship.enemie\*\*\*\*\>=20) { [color=#000087]\_root[/color].spaceship.enemie\*\*\*\* = 0; [color=#000087]\_root[/color].newLevel(); } [color=#000087]\_root[/color]["[color=blue]enemy[/color]"+i].hitFlag = [color=#000087]true[/color]; [color=#000087]\_root[/color]["[color=blue]enemy[/color]"+i].[color=#000087]gotoAndPlay/color; } } }}\</PRE\>\<HR\>\</PRE\>[/indent][font=verdana, arial, helvetica][size=2]

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

[/size][/font]

[indent]

[font=verdana,arial,helvetica][size=1]ActionScript:[/size][/font]\<HR\>\<STYLE\>PRE {font : normal normal normal 13 “Courier New”, Courier, Arial;;}\</STYLE\>

[color=#000087]onClipEvent[/color] ([color=#000087]load[/color]) { ground.[color=#000087]duplicateMovieClip[/color]("[color=blue]ground2[/color]", 100); ground2.[color=#000087]\_x[/color] = ground.[color=#000087]\_x[/color]+ground.[color=#000087]\_width[/color]; groundStartx = [color=#000087]this[/color].[color=#000087]\_x[/color]; groundSpeed=15; }[color=#000087]onClipEvent[/color] (enterFrame) { [color=#000087]if[/color] ([color=#000087]\_root[/color].spaceship.scrollStart){ [color=#000087]this[/color].[color=#000087]\_x[/color]-=groundSpeed; [color=#000087]if[/color] ([color=#000087]this[/color].[color=#000087]\_x[/color]\<= (groundStartx-ground.[color=#000087]\_width[/color])){ [color=#000087]this[/color].[color=#000087]\_x[/color]=groundStartx-groundSpeed; } } }\</PRE\>\<HR\>\</PRE\>[/indent][font=verdana, arial, helvetica][size=2]  
thanks to anyone that can help me i tried everything i know and i am not good at actions script i am barely learning so any help will be appreaciated.[/size][/font]
