# Help with delay in between spawning

**URL:** <https://forum.kirupa.com/t/help-with-delay-in-between-spawning/328885>\
**Category:** flash\
**Created:** [June 27, 2012, 10:33pm UTC](https://forum.kirupa.com/t/help-with-delay-in-between-spawning/328885 "2012-06-27T22:33:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hq231](https://avatars.discourse-cdn.com/v4/letter/h/d26b3c/32.png) [@hq231](https://forum.kirupa.com/u/hq231)\
**Post date:** [June 27, 2012, 10:33pm UTC](https://forum.kirupa.com/t/help-with-delay-in-between-spawning/328885/1 "2012-06-27T22:33:15Z")

</div>

Hi, I’m pretty new to Flash and I’m working on making a tower defense game and I am trying to set a delay between each “minion” as it spawns but with my current code each minion is being deleted when the other is spawned.

Here is my code:

package  
{

```
import flash.display.MovieClip;
import flash.events.Event;
import flash.utils.Timer;
import flash.events.TimerEvent;

public class Source extends MovieClip
{

	var minion:Array;
	public var delay:Timer = new Timer(1000);

	public function Source()
	{

		addEventListener(Event.ENTER_FRAME, loop);

		minion = new Array ;
	}
	function loop(e:Event)
	{

		if (numChildren&lt;20)
		{
			var m = new Minion ;
					
				

			delay.addEventListener(TimerEvent.TIMER, spawnDelay);
			delay.start();

			function spawnDelay(event:TimerEvent)
			{

			addChild(m);

			m.x = -40;
			m.y = 300;

			

			}

		}

	}

}

```

}
