I've been trying to run this loop with onEvents inside of it, but it doesn't seem to work. I can click the button and everything works, the inner while loop keeps repeating until an onEvent is triggered, but none of the onEvents get triggered when I click on them.
onEvent("startBtn", "click", function() {
setScreen("songScreen");
setText("songName1", "Song name: " + trackName[0]);
setText("artistName1", "Artist name: " + artistName[0]);
setText("pos1", "Song position: " + songPos[0]);
setText("pop1", "Song popularity: " + songPop[0]);
while (i < songPos.length) {
setText("songName1", "Song name: " + trackName[i]);
setText("artistName1", "Artist name: " + artistName[i]);
setText("pos1", "Song position: " + songPos[i]);
setText("pop1", "Song popularity: " + songPop[i]);
upClick();
downClick();
}
});
function upClick() {
onEvent("upImg", "click", function() {
songLiked = true;
console.log("test up");
i++;
});
}
function downClick() {
onEvent("downImg", "click", function() {
songLiked = false;
console.log("test down");
i++;
});
}
What am i doing wrong?