Copy link to clipboard
Copied
Dear all thank you for your time
I have a function called control I use to reset a game using a set interval clear interval process. I would like to stop the reset function working at certain times to allow another function to execute. I have tried using a switch and else if statements but cant seem get the right result, the console . log does not appear in the console if currentFrame is 0.So the concept is when the movie clip current frame is 9 the control function stops when at 0 the functions are allowed.I find the console only responds to the true function.
function control(){
switch(true)
{
case true:if(this.overided_mc.currentFrame==(9)){
console.log ("overided")
// other movie clips do not act
}
break;
case false :if(this.overided_mc.currentFrame==(0)){
console.log ("not overiden")
//other movie clips react to this order
}
}
}
Best Regards Peter
Copy link to clipboard
Copied
your conditional switch isn't very much of a conditional. it's a flat-out true, so it's branch is always going to executed.
ie, you don't understand how to use switch/case:
https://www.w3schools.com/js/js_switch.asp
function control(){
switch(this.overided_mc.currentFrame==(9)){
case true:
console.log ("overiden");
// other movie clips do not act
break;
case false :
console.log ("not overiden");
//other movie clips react to this order
}
}
// or, imo, better:
function control(){
switch(this.overided_mc.currentFrame){
case 9:
console.log ("overiden");
// other movie clips do not act
break;
case 0 :
console.log ("not overiden");
//other movie clips react to this order
}
}