hi, i am trying to create a hit counter in the backround of a flash application. However, i can’t seeem to get the code in flash correct to access the php script. I will give you the code and any help i greatly appreciate in advance.
Flash Code:
_root.checklot=0;
setInterval(check,1)
function check() {
if(_root.checklog == 1){
_root.gotoAndStop(2);
}else{
_root.gotoAndStop(1);
clearInterval(check);
}
}
today = Date.getDate();
visit_so = SharedObject.getLocal("visit");
if(visit_so.data.date != undefined) {
visit_so.data.date = today;
visit_so.flush();
_root.checklot = loadVariablesNum("http://www.kidsforsavingearth.org/php_inc/counter.php?visit=TRUE", 0, "GET");
}else{
if(visit_so.data.date != today) {
visit_so.data.date = today;
visit_so.flush();
_root.checklot = loadVariablesNum("http://www.kidsforsavingearth.org/php_inc/counter.php?visit=FALSE", 0, "GET");
}
}
PHP Code: (i’ve checked this and it works fine w/out flash)
<?php
function get($get) {
if ($get == 'TRUE') {
$return = FALSE;
counter ($return);
}else{
$return = TRUE;
counter ($return);
}
}
function counter($return) {
if ($return) {
increase_counter("return.txt");
}else{
increase_counter("new.txt");
}
}
function increase_counter ($filename) {
//Reading the file
$file = fopen($filename, 'r');
$line = fgets($file, 999);
fclose($file);
//Increasing the count
$count = explode("=", $line);
$count[2] = (($count[1])+1);
//Writing to file
$file = fopen($filename, 'w');
fwrite($file, 'hits='.$count[2]);
fclose($file);
}
get($_GET['visit']);
print "1";
?>
Thanks for any help,
Dan