Not A Number Loop problem
Hi,
I have an array and a number to count (dont ask me to do a for loop, because it is already a loop in the fact that it calls a function that calls it!) to count and post text to the screen, but its not increasing. It starts on Up(good) and then freezes, i created an output of the number and i get first "Undefined" then "NaN" freezes at the bottom. Can anyone help me?
Thanks,
Connah
PS.Code Here:
stop();
var score=0;
dave2.text = score;
function updateScore() {
dave2.text = ++score;
con.text=numtodo;
}
function reset() {
var finalscore=dave2.text
gotoAndPlay(1);
score=0;
finalscore=0;
dave2.text = score;
}
function dotap() {
var numtodo=1;
thechase = new Array();
thechase[1] = 1;
thechase[2] = 3;
thechase[3] = 2;
thechase[4] = 4;
var mySetting = 4;
var myTemp=0;
var totap = 0;
totap = thechase[numtodo];
var waittime = 1
if (totap==1){
dick2.text = "up";
timerup = setInterval(checkup, 1000);
}
if (totap==2){
dick2.text = "down";
timerdown = setInterval(checkdown, 1000);
}
if (totap==3){
dick2.text = "left";
timerleft = setInterval(checkleft, 1000);
}
if (totap==4){
dick2.text = "right";
timerright = setInterval(checkright, 1000);
}
myTemp = totap;
}
function checkright() {
if (Key.isDown(39)) {
if(!Key.isDown(38)){
if(!Key.isDown(40)){
if(!Key.isDown(37)){
clearInterval(timerright);
updateScore();
numtodo=numtodo+1;
dotap();
}}}
}
if(!Key.isDown(39)){
clearInterval(timerright);
reset();
}
}
function checkleft() {
if (Key.isDown(37)) {
if(!Key.isDown(38)){
if(!Key.isDown(40)){
if(!Key.isDown(39)){
clearInterval(timerleft);
updateScore();
numtodo=numtodo+1;
dotap();
}}}
}
if(!Key.isDown(37)){
clearInterval(timerleft);
reset();
}
}
function checkup() {
if (Key.isDown(38)) {
if(!Key.isDown(40)){
if(!Key.isDown(37)){
if(!Key.isDown(39)){
clearInterval(timerup);
updateScore();
numtodo=numtodo+1;
dotap();
}}}
}
if(!Key.isDown(38)){
clearInterval(timerup);
reset();
}
}
function checkdown() {
if (Key.isDown(40)) {
if(!Key.isDown(38)){
if(!Key.isDown(37)){
if(!Key.isDown(39)){
clearInterval(timerdown);
updateScore();
numtodo=numtodo+1;
dotap();
}}}
}
if(!Key.isDown(40)){
clearInterval(timerdown);
reset();
}
}
dotap();