Skip to main content
November 9, 2007
Question

Multiple loadVariables from within an interval

  • November 9, 2007
  • 1 reply
  • 307 views
I have an interval that loops every 60 seconds, and each minute it updates what the user sees on stage and uses loadVariables to send data to two php pages...


deductCredits=function(){

#code that does other stuff#

loadVariables("takeCredits.php", "" , "GET");
loadVariables("../performers/chatDone.php", "" , "GET");
}
creditInterval = setInterval (deductCredits, 60000);


I've tried multiple variations of loadVariables and the oldschool method shown here seems, for some reason to work
the best, however... sometimes the data will only make it to the database twice... and after the 2nd time it quits sending even though the client is still active and the interval is updating the information on the stage.

Is there a way to be ABSOLUTELY sure those variables get sent each time the interval calls the loadVariables? When I test this over and over myself I can't seem to get it to fail, but it is failing in some instances.
This topic has been closed for replies.

1 reply

Inspiring
November 9, 2007
use

var LV:LoadVars = new LoadVars();
var RV:LoadVars = new LoadVars();
LV.sendAndLoad(url, RV, "POST");

RV.onLoad = function(success) {
if (success) {
trace("RV has a positive return")
else {
trace("RV has not received a positive return")
}
}

for bonus you can actually have your php file spit a result back, so you can trace RV, handle it that way.
November 9, 2007
Thanks for the quick reply Helpy.

So... if the return is not positive... in the else statement...

LV.sendAndLoad(url, RV, "POST"); again?
Inspiring
November 9, 2007
well that depends. What I would do if I were you, is just monitor what the app is doing, make sure you keep your procedure clean. See if you can't trace why its failing every once in a while. If you have users its failing on - when it fails, get the script to write the failure comments to a database or something.