How to make a counter in Flash?

How can you make a counter that can be used inside a flash site? (yes a counter that counts number of visitors!)
Any tutorials on this topic? or any help?



I tried to make the countertutorial on Flashkit, but still can’t make it work… I noticed there is no explanation on the text file… Could somebody help me out?


Here’s the URL:

here try this one:

in flash:
a dynamic text box with “wordsTXT” as the instance name (not the variable)
a dynamic text box with “countTXT” as the instance name.
and for the code.
[AS]myLV = new LoadVars();
myLV.onLoad = function(success) {
if (success) {
countTXT.text = myLV.count;
} else {
wordsTXT.text = “error”;


$filename="counter.txt"; //filename make sure its the same as your text file
$fd = fopen($filename, "r") or die ("can't open file");
$fstring = fread($fd, filesize($filename));
print "&count=$fstring";

$fw = fopen($filename, "w") or die ("can't write to file");
$fcounted = $fstring + 1;
$fout = fwrite($fw, $fcounted);

(just zero, nothing else)

I think this is about as simple as it gets, it doesn’t really have any “cool features” but it should get you started in the right direction.

Make sure whatever you are testing this on supports php, if you are testing this locally, make sure you put the full path to the file ie
also make sure that you change the text files prefs so that anyone can write to it.

Thanx Robotkiller!

It’s working perfect, here’s a live demo in the leftbottom corner…



the counter text is very small on my browser (safari/macOSX) but its there and it works!

that’s strange i work on Safari and MacOSX to and it’s the same height??? i’ll look after it…

Nice to meet an apple guy to…


jellous of you guys having apples