I’m still on my Pac Man game and I’m having trouble with intervals. I set them to go off ten to five seconds apart, yet they all go off at the same time. Here is my code.
function makeGhost(alias,toClear,depth){
clearInterval(toClear);
duplicateMovieClip(this.shell, alias, depth);
if(depth==1){
this.stinky._x = 257;
this.stinky._y = 191;
var myYello:Color = new Color(stinky);
myYello.setTransform({ra:255,rb:60,ga:255,gb:60});
}
if(depth==2){
this.blinky._x = 257;
this.blinky._y = 191;
var myBlub:Color = new Color(blinky);
myBlub.setTransform({ba:60,bb:255});
}
if(depth==3){
this.twinky._x = 257;
this.twinky._y = 191;
var myRed:Color = new Color(twinky);
myRed.setTransform({ra:60,rb:255});
}
if(depth==4){
this.drinky._x = 257;
this.drinky._y = 191;
var myGreen:Color = new Color(drinky);
myGreen.setTransform({ga:60,gb:255});
}
}
function begin(){
var ghostA:Number;
var ghostB:Number;
var ghostC:Number;
var ghostD:Number;
this.interMe = setInterval(this,"dirListening",10);
ghostA = setInterval(this, makeGhost('stinky',this.ghostA,1), 5000);
ghostB = setInterval(this, makeGhost('blinky',this.ghostB,2), 10000);
ghostC = setInterval(this, makeGhost('twinky',this.ghostC,3), 25000);
ghostD = setInterval(this, makeGhost('drinky',this.ghostD,4), 30000);
}
this.onLoad = begin;
The code makes a different named ghost appear and clear the interval. That part works, but all my intervals go off instantly without delay. What am I doing wrong?