A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11337 Flash Movies | 1 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Bugra Ozden
» Title: Skatalog v9 - product catalog
» Description: Create your product catalog easly and publish on your website or Create your image gallery, documents list, portfolio. Fully XML Driven
» More by Bugra Ozden


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 5828 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: Creative DW Image Show PRO
» Description: Creative DW Image Show PRO is a Dreamweaver extension which enables the user to create multimedia presentations. It combines the features of the popular Creative DW Image Show with the ability to add professional text effects to slides (similar to After Effects). The product is very customizable: the user can choose the duration of the transition effects, the slide motion start and end position, zoom and panning type for both images and texts.


Random Links | Add your own Flash Related Links
Flash Tutorials 1280 Tutorials 7 New Tutorials Added!
What's New | Top100

» Make a Flash Slide Show Screen Saver
» Simple flash making tutorial for thanksgiving
» Create flash banner for website
» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» Unknown Tag: Title10
Random Tutorial | Add Site

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Dynamic_Content

Categories Simple PHP Live Counter For your Flash Movie
Author: Jeffrey F. Hill | Website: http://www.snowvids.com |

 
Page 4
«prev 1 2 3 4 5 next»

Part II - Setting up the PHP Script

For this part you can use the attached script by just adding it to the same directory as the PHPCounter.swf.  Not much else has to be done.  I'm going to go over the script in Detail however in the hopes that you'll have a better understanding of how it works and so that you can create your own modifications in the Future.  (For example purposes Line numbers where used here for the example - do not use line numbers in the actual script. 

1) <?
2)  $filename = "PHPCounter.txt";
3)  $fp = fopen( $filename,"r");
4)  $Old = fread($fp, 100);
5)  fclose( $fp );
6)  $Old = split ("=", $Old, 5);
7)  $NewCount = $Old[1] + '1';
8)  $New = "Count=$NewCount";
9)  $fp = fopen( $filename,"w+");
10)  if (flock($fp, 2)) {
11)  fwrite($fp, $New, 100);}
12)  fclose( $fp );
13)  print "Count=$NewCount";
14)  ?>

Line 1 - Tells the server to start processing this script as a PHP script. 

Line 2 - Sets the variable filename to the name of the text file that we are going to be using to store the number of visits or Counts.  Remember in PHP whenever you see a $ that indicates a scaler variable.

Line 3 - Opens the text file for reading.  

Line 4 - This line basically places the content of the text file into the variable Old.  

Line 5 - Closes the text file.

Line 6 - This line splits the text file where ever an = sign occurs and puts the two parts into an array that can be referenced as follows:  $Old[0] references the Count part of the string, $Old[1] references the Number part of the string.  This is important because we only want to read and add to the number and not the whole string (Count=Number). 

Line 7 - Adds 1 to the current Count. 

Line 8 - Creates a new string that can be placed into the text file. We need to add the 'Count=' part again because we got rid of it when we split the string into the array.

Line 9 - Opens the file for writing to.

Line 10 - An optional argument that locks the file (file locking) so that we do not write over the same file at the same time - this can cause the Count to reset and may cause other errors.  This is mostly important if you think a large number of people will be visiting your site at any one moment. 

Line 11 - This writes over the current text file with the New value - the count is increased by one.

Line 12 - Closes the text file for writing to.

Line 13 - Prints out Count=(The new Count) which is returned to the Flash movie - the value of Count then appears in the dynamic text box named Count in the Flash movie. 

Line 14 - Ends the PHP script.

That's it for the script.  The last and probably most important thing that your going to have to do is change the permissions of the Text file that your using - in this case: PHPCounter.txt - To 777 you can do this with Telnet by using the command: chmod 777 PHPCounter.txt in the directory in which it resides.  You can also do this with some ftp programs such as ws_ftp. 

«prev 1 2 3 4 5 next»

» Level Intermediate

Added: : 2001-08-23
Rating: 7.94 Votes: 131
Hits: 5581
» Author
No details available.
» Download
Download the files used in this tutorial.
Download (54 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs