# Need delay after detecting the sound

**URL:** <https://forum.kirupa.com/t/need-delay-after-detecting-the-sound/329618>\
**Category:** flash\
**Created:** [September 23, 2012, 9:42am UTC](https://forum.kirupa.com/t/need-delay-after-detecting-the-sound/329618 "2012-09-23T09:42:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zubair\_Affan](https://avatars.discourse-cdn.com/v4/letter/z/e9c0ed/32.png) [@Zubair\_Affan](https://forum.kirupa.com/u/Zubair_Affan)\
**Post date:** [September 23, 2012, 9:42am UTC](https://forum.kirupa.com/t/need-delay-after-detecting-the-sound/329618/1 "2012-09-23T09:42:24Z")

</div>

I need to place a delay as soon as the “this.gotoAndStop(currentFrame + 30);” is executed. the purpose of this script is to move the timeline after mic read the sound in time interval of 5 sec… for example, current frame is 1 then after detecting the sound through mic it should goto and stop at 31, again on sound detecting it should move to 61 and so on…

Any response will be high appreciated.  
Thanks in advance…

import flash.display.FrameLabel;  
var myMic:Microphone = Microphone.getMicrophone();  
myMic.setUseEchoSuppression(true);  
myMic.setLoopBack(true);  
var st:SoundTransform = new SoundTransform(0);

this.addEventListener(Event.ENTER\_FRAME,startSpeaking);// creates enterframe event  
function startSpeaking (e:Event)  
{

```
			if(myMic.activityLevel== -2 || myMic.activityLevel&lt;=50)
			{
				stop();				
				myMic.soundTransform = st;
							
			}
			else
			{
		 	this.gotoAndStop(currentFrame + 30);
			myMic.soundTransform = st;
			}
		}
```
