# \[AS\] setInterval corrupting function?

**URL:** <https://forum.kirupa.com/t/as-setinterval-corrupting-function/196400>\
**Category:** flash\
**Created:** [August 8, 2006, 3:39am UTC](https://forum.kirupa.com/t/as-setinterval-corrupting-function/196400 "2006-08-08T03:39:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jopper](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jopper](https://forum.kirupa.com/u/jopper)\
**Post date:** [August 8, 2006, 3:39am UTC](https://forum.kirupa.com/t/as-setinterval-corrupting-function/196400/1 "2006-08-08T03:39:24Z")

</div>

Hi. I’ve made a function that hides a button, waits 5 seconds and turns it back on. When I run hideBtn(); for the three buttons only the first button works however the traces successfully output:

[SIZE=“1”]\_level0.menuMC.homeBut  
\_level0.menuMC.aboutBut  
\_level0.menuMC.contBut[/SIZE]

I’m thinking there is a problem with the setInterval. When I run the clearInterval the first time does it ruin it for the rest of the calls?

I’m sure there is a better way of doing it. Thanks for any help.

[SIZE=“1”]function hideBtn(cp) {  
var currPath = cp;  
currPath.\_visible = false;  
wait = function() {  
currPath.\_visible = true;  
clearInterval(evoClr);  
}  
evoClr = setInterval(wait, 5000);  
trace(currPath);  
}

hideBtn(this.\_parent.homeBut);  
hideBtn(this.\_parent.aboutBut);  
hideBtn(this.\_parent.contBut);[/SIZE]
