# Little problem with setInterval();

**URL:** <https://forum.kirupa.com/t/little-problem-with-setinterval/209528>\
**Category:** flash\
**Created:** [December 9, 2006, 8:49pm UTC](https://forum.kirupa.com/t/little-problem-with-setinterval/209528 "2006-12-09T20:49:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![koolkrasher](https://avatars.discourse-cdn.com/v4/letter/k/c6cbf5/32.png) [@koolkrasher](https://forum.kirupa.com/u/koolkrasher)\
**Post date:** [December 9, 2006, 8:49pm UTC](https://forum.kirupa.com/t/little-problem-with-setinterval/209528/1 "2006-12-09T20:49:22Z")

</div>

Hello Folks, I am making a dreidel game for my boss and it all works good except i am having a rather hard time setting a delay for all the scripts in the functions to fire. I understand how they work but i think i am implementing them wrong. If someone could take a look at my code and help me out thad be great. rite now the set interval is set to have a 3 second delay before it switches players but nothing is happening.

var nPlayer:Number = 1;  
var pot:Number = 0;  
var p0total:Number = 10;  
var p1total:Number = 10;  
var player:String ="";  
var gameOver:String = “”;  
var rules:String = “”;  
///////////////////////////  
///////////////////////////spinner button  
[COLOR=red]**this.spinbtn.onRelease = function() {**[/COLOR]  
**[COLOR=red]timercp = setInterval(changePlayer, 3000);[/COLOR]**  
**[COLOR=red]spinner();[/COLOR]**  
**[COLOR=red]changePlayer();[/COLOR]**  
**[COLOR=red]gameover();[/COLOR]**  
**[COLOR=red]};[/COLOR]**  
/////////////////////////// gameover fucntion  
function gameover() {  
if (p0total == 0) {  
rules = “Game Over Player 2 Wins!”;  
} else if (p1total == 0) {  
rules = “Game Over Player 1 Wins!”;  
}  
}  
//////////////////////////random spinner  
function spinner() {  
var nspin:Number = random(10+2);  
if (nspin == 0) {  
this.container.loadMovie(“shin.swf”, “”);  
shin();  
} else if (nspin == 1) {  
this.container.loadMovie(“hey.swf”, “”);  
hey();  
} else if (nspin == 2) {  
this.container.loadMovie(“gim.swf”, “”);  
gimel();  
} else if (nspin == 3) {  
this.container.loadMovie(“nun.swf”, “”);  
nun();  
} else if (nspin == 4) {  
this.container.loadMovie(“shin.swf”, “”);  
shin();  
} else if (nspin == 5) {  
this.container.loadMovie(“hey.swf”, “”);  
hey();  
} else if (nspin == 6) {  
this.container.loadMovie(“gim.swf”, “”);  
gimel();  
} else if (nspin == 7) {  
this.container.loadMovie(“nun.swf”, “”);  
nun();  
} else if (nspin == 8) {  
this.container.loadMovie(“shin.swf”, “”);  
shin();  
} else if (nspin == 9) {  
this.container.loadMovie(“hey.swf”, “”);  
hey();  
} else if (nspin == 10) {  
this.container.loadMovie(“gim.swf”, “”);  
gimel();  
} else if (nspin == 11) {  
this.container.LoadMovie(“nun.swf”, “”);  
nun();  
}  
}  
//////////////////////////change player fucntion  
[COLOR=red]**function changePlayer() {**[/COLOR]  
**[COLOR=red]if (nPlayer == 0) {[/COLOR]**  
**[COLOR=red]nPlayer++;[/COLOR]**  
**[COLOR=red]player = “Player Two”;[/COLOR]**  
**[COLOR=red]this.pointer.gotoAndStop(2);[/COLOR]**  
**[COLOR=red]} else if (nPlayer == 1) {[/COLOR]**  
**[COLOR=red]nPlayer–;[/COLOR]**  
**[COLOR=red]player = “Player One”;[/COLOR]**  
**[COLOR=red]this.pointer.gotoAndStop(1);[/COLOR]**  
**[COLOR=red]}[/COLOR]**  
**[COLOR=red]clearInterval(timercp);[/COLOR]**  
**[COLOR=red]}[/COLOR]**  
///////////////////////////  
function hey() {  
rules = “Hey-Take half the pot”;  
if (nPlayer == 0) {  
p0total = Math.round(p0total+(pot/2));  
Math.round(pot/2);  
if (pot=1) {  
pot = 0;  
}  
} else if (nPlayer == 1) {  
p1total = Math.round(p1total+(pot/2));  
Math.round(pot/2);  
if (pot=1) {  
pot = 0;  
}  
}  
}  
///////////////////////////  
function gimel() {  
rules = “Gimel-Take the pot”;  
if (nPlayer == 0) {  
p0total = (pot+p0total);  
} else if (nPlayer == 1) {  
p1total = (pot+p1total);  
}  
pot = 0;  
}  
////////////////////////////  
function nun() {  
rules = “Nun-Nothing happens”;  
}  
////////////////////////////  
function shin() {  
rules = “Shin-Add one to pot”;  
if (nPlayer == 0) {  
p0total–;  
pot++;  
} else if (nPlayer == 1) {  
p1total–;  
pot++;  
}  
}  
/////////////////////////////

any ideas leme know  
thanks,  
Kool
