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?

Andreas:}

Hello,

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?

Andreas

Here’s the URL: http://www.flashkit.com/tutorials/Dynamic_Content/Simple_P-Jeffrey_-656/index.php

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.load(“path_to/your_php_file.php”);
myLV.onLoad = function(success) {
if (success) {
countTXT.text = myLV.count;
} else {
wordsTXT.text = “error”;
}
};[/AS]

PHP:


<?php
$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";
fclose($fd);

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

TEXT FILE:
0
(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 http://www.blahblahblah.com/myphpfile.php).
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…www.salmo.nl

Cheers!

Andreas::slight_smile:

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…

Andreas

jellous of you guys having apples