# Simple time delay in AS2

**URL:** https://forum.kirupa.com/t/simple-time-delay-in-as2/317186
**Category:** flash
**Created:** [December 13, 2010, 12:44pm UTC](https://forum.kirupa.com/t/simple-time-delay-in-as2/317186 "2010-12-13T12:44:03Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ksk](https://avatars.discourse-cdn.com/v4/letter/k/ac8455/32.png) [@ksk](https://forum.kirupa.com/u/ksk)
#### Post date: [December 13, 2010, 12:44pm UTC](https://forum.kirupa.com/t/simple-time-delay-in-as2/317186/1 "2010-12-13T12:44:03Z")

</div>

This may be a bit too late… but here goes for all those ppl who still code in AS2:

```auto

//Intervals of delay: IntervalID... currently set as 500 milliseconds.
//Following line says that countDown() function will be called every 500 milliseconds.
var IntervalID:Number = setInterval(countDown, 500);

//reps can be set to the number of times we need consecutive 500ms delay.
var reps:Number = 4;

function countDown(){	
	if(reps == 0){
		clearInterval(IntervalID);	//When all reps done, the 500 ms intervals are not generated
trace("|");
}
	else{
		reps--;
trace("*");
}
}

```
