> > Tutorials > T1097

Flash page hit counter for your website.

You can use loadVariables function to call php file and display page hit counter in your Flash project:

PHP file must return the result in the following format


Where 1324 is the current page hit count.

You can download the counter code and upload it with ftp to your website.

flash counter

  1. Launch Alligator Flash Designer and choose “Blank document”.
  2. Choose “Frame” > “Frame Size” to set movie size to 600 x 250.
  3. Choose “Frame” > “ActionScript” and paste the following code:
    myData = new LoadVars();myData.onLoad = function() {  Edit1 = this.counter1;};myData.load("");


  4. Choose “Edit Field” tool and draw an edit field.
  5. Choose “Select” tool. Double click the edit field, change “Variable name” to “Edit1”.
  6. Choose Frame > Frame Delay and check Stop at this frame, click OK.
  7. Press F9 for preview.

counter.php file contains the following code:

<?php$f = fopen("counter1.txt","r+");$counter1 = fread($f,filesize("counter1.txt"));$counter1++;fseek($f,0);fwrite($f,$counter1);fclose($f);	echo "counter1=" . $counter1;?>

The counter1.txt file keeps the current hit count value. Create a new text file with Notepad and name it counter1.txt. Open it and enter initial value (for example 1324) in a single line without line break at the end.
You have to upload initial counter1.txt file to your website.

If the counter does not increment make sure the counter works directly in the browser. Open your php file with the browser (running it through the server) and refresh it few times to see if the counter works.

Try this link first: to see how the counter increments.

If the counter does not work in the browser make sure the counter1.txt file has proper permissions. Ask your webmaster to change permissions to 755.


get flash