@remy51720 ![]()
If this one do not work… (i did not test it)…
$w.onReady(function () {
{setInterval(async function () {
let myMSB = $w("#statebox10")
if (myMSB.currentState === "1") {await myMSB.changeState("2");}
else {await myMSB.changeState("1");}
console.log(myMSB.currentState)
}, 5000);
});
You can also do it like this…
$w.onReady(function () {
setInterval(()=> {
let myMSB = $w("#statebox10")
if (myMSB.currentState === "1") {
myMSB.changeState("2"), console.log(myMSB.currentState);
}
else {myMSB.changeState("1"), console.log(myMSB.currentState);}
},5000);
});
Found an SYNTAX-MISTAKE here…
--> { <-- not needed setInterval(async function () {
or trying this method… (your first try)
$w.onReady(function () {
setInterval(()=> {
let myMSB = $w("#statebox10")
if (myMSB.currentState === "1") {
myMSB.changeState("2").then(()=>{console.log(myMSB.currentState);})
}
else {myMSB.changeState("1").then(()=>{console.log(myMSB.currentState);})
},5000);
});