Do you want to know how many visitors surfed on your website? I guess your answer is yes. But how to do and which tool can create such a counter? Now, I will solve all the problems and show you the steps to create a counter.
Here, I will make this visit counter by Sothink SWF Quicker. Sothink SWF Quicker is a Flash editor to make Flash-based applications for website. It can create Flash games, Flash videos, interactive animations, text effects, slide shows, etc. By following the steps, you will get the counter like this:
Prepared Work and the Softwares Have Been Used:
- Make sure your web site server has PHP installed
- Adobe Dreamweaver CS3
- Get the wonderful images, and use them to beatify your counter
- Install Sothink SWF Quicker
Steps:
Make Background Image
- Launch Sothink SWF Quicker and you will see the above screenshot. Click the canvas, and then set the canvas size in the "Properties" panel.
- Import an image (Get the 1.jpg from zip file). Right click the empty area in the "Library" panel, and choose the option "Import…" from the context-menu.
- Drag this image to the canvas, and adjust its position, size, etc in the "Transform" panel. You will see the frame 1 changes into keyframe from blank keyframe in layer 1.
- Copy the image, and paste it into the canvas. Choose this image, and set its properties in the "Transform" panel.
- Make sure the background image always showing. We insert the keyframe in the frame 40.
Add Text and Write ActionScript for Them
- Add a new layer by clicking the button (see figure), and then add text on it.
- Choose the tool "Text" in the "Tools" panel. And drag a rectangle on the canvas, input the text "Count" in it. You can set the text properties in the below "Properties" panel.
- Still choose the tool "Text" in the "Tools" panel. And drag another rectangle on the canvas, enter the "Properties" panel, set Type as "Dynamic" and Var as "count". You will see the frame 1 changes into keyframe from blank keyframe in layer 2.
- Select the frame 2, and right-click to choose "Convert to Keyframe" from context-menu.
- Select the frame 40, and right-click to choose "Insert Keyframe" from context-menu.
- The timeline will display like this:
- Choose the frame 1 in the layer 2, and enter the "Action" panel, input the below ActionScript:
this.loadVariables("count.php?num="+random(99));
- Note: count.php should be the same name with your PHP page.
- Choose the frame 2 in the layer 2, and enter the "Action" panel, input the below ActionScript:
this.loadVariables("count.txt?num="+random(999));
- Choose the frame 40 in the layer 2, and enter the "Action" panel, input the below ActionScript:
gotoAndPlay(2);
Export the Flash Counter
- After all the work is done, you can click "Export" button to export this Flash counter.
- Choose a directory to save this SWF file, and name it "count.swf".
Make a PHP Page
- Open your Dreamweaver, and create a PHP page named as "count.php".
- Enter the "Code" view, and remove all the code in it. You need to paste the below code into the Dreamweaver.
<?php $count = file_get_contents("count.txt"); $count = explode("=", $count); $count[1] = $count[1]+1; $file = fopen("count.txt", "w+"); fwrite($file, "count=".$count[1]); fclose($file); print "count=".$count[1]; ?>
Make an HTML Page
- Open your Dreamweaver, and create a PHP page named as "c.html".
- In the "Design" view, click "Insert > Media > Flash" to insert the “count.swf” into the page.
- After inserting the Flash, the result will be like this:
At last, upload all the files include count.swf, count.php, and c.html to the server, which PHP is installed on it (make sure these files are saved in one folder), to test if the counter works well.
Hope this tutorial can help you.