I am using flash to develop a behavioral experiment. The experiment is designed to have two people work on tasks together, simultaneously. In order to do this, a text file must frequently be called from a server. I use setInterval to do this as a way of keeping the players in sync.

For instance, after the practice round, I give Player 2 a wait screen with no continue button. As soon as Player 1 has also finished the practice round and has clicked her continue button, the program sends a variable with value "Yes" to the external text file. Player 2's program is constantly calling the text file on the server (using setInterval set to 1000ms) until it finds that specific variable with the value "Yes". At this point, the continue button is made visible on Player 2's screen.

setInterval does not seem to be consistently called. I experience erratic behavior: Sometimes it works immediately, sometimes it does not. When it does not work, I believe it is still calling setInterval, because if I leave the screen up, the continue button will eventually show up, even if it takes over 5 minutes to do so!!

I tried sticking updateAfterEvent() in the function called by setInterval to make sure the stage was being updated after finding the variable, but this did not seem to solve the problem.

CODE (for only one of the frames on which this is happening):
//////Continue button///////
btnContinue.onRelease = function(){
               //The following text will be read by first screen of Stage1and2_Boss before
               //the continue buttone will appear.
     submitDataToTextfile("append",pairid+"_data.txt","workerfinishedpract ice","Yes");
//Make button invisible until the variable "practicefinished" takes on the value "Yes".
btnContinue._visible = false;
function endframe7(){
               //"URL" is actually set to the web address of the server. I have removed it for this example.
     myVars.onLoad = function(success){
          if (success) {
               if (myVars.practicefinished == "Yes"){
                    btnContinue._visible = true;
CheckInterval_Worker = setInterval(endframe7,1000);