# Help with my 2d scrolling shooter

**URL:** https://forum.kirupa.com/t/help-with-my-2d-scrolling-shooter/255801
**Category:** Uncategorized
**Created:** [March 27, 2008, 5:02am UTC](https://forum.kirupa.com/t/help-with-my-2d-scrolling-shooter/255801 "2008-03-27T05:02:54Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![glenn101](https://avatars.discourse-cdn.com/v4/letter/g/94ad74/32.png) [@glenn101](https://forum.kirupa.com/u/glenn101)
#### Post date: [March 27, 2008, 5:02am UTC](https://forum.kirupa.com/t/help-with-my-2d-scrolling-shooter/255801/1 "2008-03-27T05:02:54Z")

</div>

Hey guys,  
I need help with my first flash game, so far I have a scrolling background, a player ship that is able to fire lazers and move, and an enemy which is my problem. The problem is that I want to have 3 enemies continously spawning in random positions on the y-axis, I have tried to set 3 on frame 1 in my actions frame but for some reason it doesn’t read that code at all it only seems to read my background frames actions (for the scrolling) and all my movie clips.  
I can have 1 enemy though doing as I want it to by scrolling but I can’t seem to get more. Here is parts of my code so far.

this is the code for my scrolling background in frame 1

Code:  
stop();  
for (i=1; i\<=100; i++)  
{  
t1.duplicateMovieClip( “t1”+i, i+100,t1 );  
}  
for (i=1; i\<=40; i++)  
{  
t2.duplicateMovieClip( “t2”+i, i+300,t2 );  
}  
for (i=1; i\<=20; i++)  
{  
t3.duplicateMovieClip( “t3”+i, i+400,t3 );  
}  
function loadstar(varname) //loads the clip  
{  
\_root[varname].\_x=random(650);  
\_root[varname].\_y=random(400);  
\_root[varname].speed=random(4)-5;  
}  
function movestar(varname) //stars  
{  
\_root[varname].\_x+=\_root[varname].speed;  
if(\_root[varname].\_x\<10)  
{  
\_root[varname].reset();  
}  
}

This is the code for my enemy movieclip

Code;  
onClipEvent (load){  
function reset(){  
this.\_x=650;  
this.\_y=random(200)+100;  
EnemyoneSpeed=random(6)+1;  
this.gotoAndStop(1);  
}  
reset();  
}  
onClipEvent (enterFrame){  
if(\_root.Player\_mc.loopStart){  
this.\_x-=EnemyoneSpeed;  
}else{  
this.\_x-=EnemyoneSpeed;  
}  
if(this.\_x\<-10){  
reset();  
}  
}

and now this is the code for frame 1 actions

Code:  
numEnemyone=3;  
for(i=2; i\<=numEnemyone; i++) {  
Enemyone\_mc.duplicateMovieClip(“Enemyone”+i, i+100);  
}

If none of this seems to make much sense just open my flash document.

I hope someone can help,  
thanks in advance,  
glenn.
