# Possible to use setinterval to control this script?

**URL:** <https://forum.kirupa.com/t/possible-to-use-setinterval-to-control-this-script/263342>\
**Category:** Uncategorized\
**Created:** [June 14, 2008, 6:16pm UTC](https://forum.kirupa.com/t/possible-to-use-setinterval-to-control-this-script/263342 "2008-06-14T18:16:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Helen\_N](https://avatars.discourse-cdn.com/v4/letter/h/53a042/32.png) [@Helen\_N](https://forum.kirupa.com/u/Helen_N)\
**Post date:** [June 14, 2008, 6:16pm UTC](https://forum.kirupa.com/t/possible-to-use-setinterval-to-control-this-script/263342/1 "2008-06-14T18:16:56Z")

</div>

I am using this random motion script, i tried to control the speed by using microphone… the only possible way so far i know :crying: is using setinterval and links the interval together with mic value…:crying: but is it possible? i have tried few times and it is not working so far…:crying:

acceleration = 3  
newpos = function () {  
ranx = Math.round((Math.random ()\*300));  
rany = Math.round ((Math.random ()\*450));  
}  
newpos();  
this.onEnterFrame = function() {  
this.\_x += ((ranx-this.\_x)/acceleration);  
this.\_y += ((rany-this.\_y)/acceleration);  
if (Math.round(this.\_x) == ranx || Math.round(this.\_y) == rany) {  
newpos();  
}  
};

---

<div class="post-metadata">

**Author:** ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)\
**Post date:** [June 14, 2008, 6:20pm UTC](https://forum.kirupa.com/t/possible-to-use-setinterval-to-control-this-script/263342/2 "2008-06-14T18:20:10Z")

</div>

what did you do with the microphone ???

---

<div class="post-metadata">

**Author:** ![Helen\_N](https://avatars.discourse-cdn.com/v4/letter/h/53a042/32.png) [@Helen\_N](https://forum.kirupa.com/u/Helen_N)\
**Post date:** [June 14, 2008, 6:31pm UTC](https://forum.kirupa.com/t/possible-to-use-setinterval-to-control-this-script/263342/3 "2008-06-14T18:31:37Z")

</div>

my project needs to use the mic to control the speed…but i cant figure it out ☹

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [June 14, 2008, 8:53pm UTC](https://forum.kirupa.com/t/possible-to-use-setinterval-to-control-this-script/263342/4 "2008-06-14T20:53:04Z")

</div>

```auto
mic = Microphone.get();
mic.setUseEchoSuppression(true);
mic.useEchoSuppression;
myMC.attachAudio(mic);
onEnterFrame = function () {
	if (myMC._x > Stage.width - 50) {
		myMC._x = 50;
	} else {
		myMC._x += mic.activityLevel;
	}
};

```
