# as2 little help with setInterval

**URL:** <https://forum.kirupa.com/t/as2-little-help-with-setinterval/284758>\
**Category:** flash\
**Created:** [March 23, 2009, 12:36pm UTC](https://forum.kirupa.com/t/as2-little-help-with-setinterval/284758 "2009-03-23T12:36:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcogiannini](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@marcogiannini](https://forum.kirupa.com/u/marcogiannini)\
**Post date:** [March 23, 2009, 12:36pm UTC](https://forum.kirupa.com/t/as2-little-help-with-setinterval/284758/1 "2009-03-23T12:36:46Z")

</div>

Hi all,  
I’ve got some problems with this bunch of code. I need to let start biciccioCheFa function and then apply a setInterval to frenaParti function.

Now the setInterval goes, and stop after the counter reach 10. But I can’t send any value to biciccioCheFa function, or at least it don’t understand the biciccio value (frenaParti rule a landscape on the bottom of the stage that stop and goes any time the user click on the main menu, biciccio is a bikerider, he also stops and goes following the landscape, but his animation is a bit slow, so I figured out a setInterval for the landscape…)

If I turn off the setInterval code and I put a callback for biciccioCheFa function inside the frenaParti function, it reads just the biciccio value (I tried it)

Question: what can I do in order to make biciccioCheFa function read instructions sent from frenaParti?

// 50 milliseconds intervals, till 10, then rub out the interval  
var intervalId:Number;  
var count:Number = 0;  
var maxCount:Number = 10;  
var duration:Number = 50;

function executeCallback():Void {  
trace("executeCallback intervalId: " + intervalId + " count: " + count);  
if(count \>= maxCount) {  
clearInterval(intervalId);  
frenaParti();  
count = 0;  
}  
count++;  
}

function tutto () {  
trace (“tutto”);  
// This rule a switch/case function about biciccio behaviour);  
trace (“biciccio” + biciccio);  
biciccioCheFa ();  
// setInterval per delay frenaParti  
intervalId = setInterval(this, “executeCallback”, duration);  
}  
// This about landscape  
function frenaParti () {  
if (vai\_Avanti == true) {  
vai\_Avanti = false;  
rallenta\_Stop = true;  
trace (“STOP!”);  
// the variable that tell what the bikerider is actually doing  
biciccio = “frena”;  
} else if (rallenta\_Stop == true) {  
rallenta\_Stop = false;  
vai\_Avanti = true;  
trace (“GO!”);  
biciccio = “riparte”;  
} else {  
vai\_Avanti = false;  
rallenta\_Stop = true;  
trace (“STOP!”);  
biciccio = “frena”;  
}  
}

Thanking you in advance  
ciao
