PDA

View Full Version : php to flash =>cache issues


tango88
03-02-2007, 01:16 AM
Briefly, I have a game that tracks high scores, stored on a database. The game reads the scores using a php script like so:

...$num=mysql_numrows($result)-1;


$name1=mysql_result($result,$num,"name1");
$score1=mysql_result($result,$num,"score1");
$month=mysql_result($result,$num,"month");



$passIn = "" ;
$passIn .= "name1=" . $name1 . "&" ;
$passIn .= "score1=" . $score1 . "&" ;
$passIn .= "month=" . $month . "&" ;
$passIn .= "serverdate=" . $serverdate . "&" ;


echo $passIn ;...

Then I use loadVars to get the values into flash.

However, it seems that when players go back and play again, they get the old scores from the temporary Internet cache. They can then beat the old score and overwrite a newer score which is actually higher.


Is there a way I can get the values into flash without leaving a cache file? I'm at the limit of my (narrow) programming abilities with this one.

tango88
03-02-2007, 02:25 AM
Got it, I think.

No need to redo the code, just add the following to the php file:

header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");


Seems to work - that's two extremely useful lines of code!

capz_man
03-22-2007, 05:46 AM
hello,i've got similar problem,when i'm upload my flash online tutorial n have to reviewing it,i have to clear my cache first,if not it will shows the old version.i'm using aspx to embedded the flash.

jsonchiu
03-22-2007, 06:23 AM
or add a time stamp to the url...
function getTimeStamp():String
{
var myDate:Date = new Date()
var timeStamp:String = myDate.getHours() + "|" + myDate.getMinutes() + "|" + myDate.getSeconds() + "|" + myDate.getMilliseconds();
return timeStamp;
}

and when you are sending...
myLoadVars.sendAndLoad("myfile.php?" + getTimeStamp(), myLoadVars, "POST");

peptobismol
03-23-2007, 07:44 PM
you can do this too.. it's quick, dirty and easy.

myLoadVars.sendAndLoad("myfile.php?" + random(5000), myLoadVars, "POST");

freaklancer
03-31-2007, 09:12 AM
you can do this too.. it's quick, dirty and easy.

myLoadVars.sendAndLoad("myfile.php?" + random(5000), myLoadVars, "POST");

cool :p ain't seen this one yet.