I've seen many flash counters online but most of them increment when thepage is refreshed. The trick is to set a cookie on the visitor's pc (inthe temporarily internet files) with his ip in it.
Whenthe page is refreshed the movie checks, using php and LoadVars, if theip retreived matches the ip in the cookie or if the cookie exists andthen according to the info set the counter which is retreived from a.txt file.

LoadVars:
This function enables you to load, send, sendAndLoad outside info to the movie.


var lVars:LoadVars = new LoadVars;
var rVars:LoadVars = new LoadVars;
//loading info from .txt file
lVars.load("myText.txt");
//sending info to a page. the info are added as a querystring to the url
lVars.name = "ronny";
lVars.send("mypage.php","_blank","POST"); //lVars will open a new page sending the variable name=ronny to mypage.php
//mypage.php?name=ronny
lVars.sendAndLoad("mypage.php", rVars, "POST");
//sendAndLoad is used to send variables to a page and loads a result from the page. I chose to load the variables sent from
//mypage.php into another LoadVars called rVars. Now to get what was loaded in rVars:
rVars.onLoad = function(success:Boolean){
if(success){

}else{

}
}


Now that's a brief definition of LoadVars. If you want to know more check the help inside flash.

Thistutorial has 4 files: 2 php files ( i prefer to have each script on afile), a flash movie, and a .txt file [setCt.php, setIP.php,visits.swf, visitorCount.txt]


Now let's start with the actionscript code:

insert a dynamic text field into the flash movie and name the instance: counterTxt
And here's the code you place on the frame

var sendVars:LoadVars = new LoadVars;
var getVars:LoadVars = new LoadVars;
var rCounts:LoadVars = new LoadVars;
var getCounts:LoadVars = new LoadVars;
var setCounts:LoadVars = new LoadVars;
var count:Number = 0;
counterTxt.text = "Loading Visitors' Count...";

getCounts.onData = function(lastStr:String){
if(lastStr != undefined){
count = parseInt(lastStr);
sendVars.sendAndLoad("http://www.urSiteNameHere.com/setIP.php", getVars, "POST");
}else{
counterTxt.text = "Loading Count failed!";
}
}

getCounts.load("http://www.urSiteNameHere.com/visitorCount.txt");

getVars.onLoad = function(success){
if (success){
if (getVars.IP == "0"){
count++;
counterTxt.text = count;
setCounts.count = count;
setCounts.sendAndLoad("http://www.urSiteNameHere.com/setCt.php", rCounts, "POST");
}else{
counterTxt.text = count;
}
}else{
counterTxt.text = "Nothing was loaded :(";
}
}