I am back already I decided since this was an easy one, I would go ahead and do it
We are branching off of my writing to txt files tutorial. I am assuming you will understand most parts of my php file because of this
This one we won't need any pictures either, because we will assume you have looked at the other one and understand when I say variable name and the such...
So to start off with our swishmax..
Create your counter text. We will make this a DYNAMIC TEXT box, with the name of..counter(original, huh?)
Now I want you to place this at your very first frame(Onload, actually) of your scene. This means the main root movie.
As you know already, we are loading my counter.php to get the data. The one change this time is I am using GET. You can still use post, but I have always used GET when I wanted to GET data from the php file, and POST when I wanted to give data to it.
Now we will move onto the php code. I will comment it where we need to
[php]<?php
$filename = "count.txt";
$file = fopen( $filename, 'r' ); //We are only reading from the file this time, thus the r instead of w
$lines = file($filename);
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Get's the data from the file. http://www.php.net/file. It seperates
the data into an array, which I will access in the next line.
*/
$count = $lines[0];
/* ^^^^^^^^^^^^^^^^^^^^^^^^
We are now getting the data from the array so we can use it in the script
*/
$count++;
// Adding one to the count, because we are counting each visit, and if this is loaded
// that means there is a new visitor to add
echo "&counter=".$count; //Giving flash the variable named counter so it can be used
fclose( $file ); //Closing the file
$file = fopen($filename, "w" ); //Now we are gonna re-write the file with the new count of visitors
fwrite( $file, $count );
fclose( $file );
?>[/php]
I know this is a little less commented, so anything you don't understand, just tell me. This is expecting you understand a little bit more than the last one about writing to a text file