Flash Hit Counter Using ActionScript and PHP

by Hiroshi on October 26, 2008

in Actionscript, Adobe Flash, Counter, Flash PHP

We can create a simple hit counter using flash and PHP script which uses text file for storing hits. I have used a blank count.txt file, and php file. Create a dynamic text field in flash movie and name it count and you are done. Name the flash movie counter.swf or whatever you like.

PHP File Code (counter.php)

<?php 
//Reading the file
$count = file_get_contents("count.txt"); //Increasing the count
$count = explode("=", $count);
$count[1] = $count[1]+1;
//Writing to file
$file = fopen("count.txt", "w+");
fwrite($file, "count=".$count[1]);
fclose($file);
//Returning the count
print "count=".$count[1];
?>

Flah Movie – Dynamic Text Field Count Scripting

this.loadVariables("counter.php");

Download Flash PHP Hit Counter

Related Posts

Previous post:

Next post: