sinisterduke 0 Newbie Poster

So i've been making my first flash game the last few days, and everything was going quick and smoothly.... until yesterday. I've had this problem I can't fix, and have spent about as much time as I've spent on the rest of the game trying to fix it, only to no avail.

Anyway, in this part of the code i'm spawning a lazer. The problem is, multiple lazers are being spawned. I commented some things out so that a lazer should spawn only under one condition, but even so multiple green lazers are now being spawned. Could someone possibly help me? I've been killing myself over a seemingly small problem instead of advancing in the game. Anyway, heres the code:

if (enemytimer > 90) 
			{
				enemytimer = 0;
				
				randomnum=(Math.floor(Math.random()*4));
				if (randomnum == 0) 
				{
					var thelaser = _root.attachMovie("green lazer", "green lazer"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
					thelaser.thecolor = "green";
				}

				else if (randomnum == 1) 
				{
					//var thelaser = _root.attachMovie("red lazer", "red lazer"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
					//thelaser.thecolor = "red";
				}

				else if (randomnum == 2) 
				{
					//var thelaser = _root.attachMovie("blue lazer", "blue lazer"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
					//thelaser.thecolor = "blue";
				}
				else if (randomnum == 3) 
				{
					//var thelaser = _root.attachMovie("yellow lazer", "yellow lazer"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
					//thelaser.thecolor = "yellow";
				}
				
			}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.