Flash Labs > Lab 8: Logging User Data (via PHP)
OverviewIn this lab you will learn how to log user behavior and data from your Flash-based UI prototype in to a text file. Since the Flash player cannot write to a file directly, you will accomplish this by having the SWF file talk to a PHP script. GoalsLearn how you can use Flash to write information about what happened to an external text file. Become introduced to how PHP can complement Flash. ExampleThis example will log the date/time of when it's been accessed by a user. View the log here. Note: If this example isn't running on a webserver with PHP support, the user data will not get logged. ...there is still a scary woosh sound when the palette opens. |
Steps
Optional: Download the working files for this lab
1. Turn on Web Sharing by going to System Preferences > Sharing and turning on Personal Web Sharing. Steps for setting up OS X with PHP:
Just download the PHP installer and run it. If you have problems, detailed instructions are provided here. Creating the .PHP file:
So now that your machine is configured, you'll need to create a PHP file that will write information to a text file.
How to call the PHP file from Flash:
From Flash, all you need to do is call the PHP file using a POST command, and the PHP file will be able to access the variables in the SWF file. Here is the line of code I used to call the PHP file:
Make sure when you check the files, you view them in a browser using the address of your machine, and not by referencing the file on disk.
Learn More
Macromedia's notes on Flash and PHP |