/*
If you are looking to do some simple interaction between Flash MX and php,
here is an extremely basic model to get you started. The Flash file has a simple
Input Text field which allows the user to enter text (ie a textbox). The flash
then passes the textfield to the php script for processing/database interaction etc.
The idea is a form made in Flash, but processing by php/mysql (or whatever). If you want
to handle all GUI in Flash, see the links below for more info.
All "Actions" or "Action Script" located in frame 1, layer 1.
In Flash, create an Input Box with an instance name of myTextBox.
Create a "submit button" using Insert>New Symbol>Movie Clip.
Dont use the PushButton Component or you will have to add
scripting to that component (ie outside Frame1 Layer1). Keeping all the
Action Script in Frame1 makes for a simpler example.
Next, click on the background in Frame1 (the "Properties" dialog
should show the Background color). Hit F9 to show actions for Frame1.
Enter the below code:
*/
//Create object to hold vars
dataSender = new LoadVars();
//Define submit button behavior
submit_button.onRelease = function() {
//assign properties to LoadVars object created previously
//myTextBox is instance name for input text box
//foo will be the var passed to php (ie $foo)
//Set foo to the text entered by user
dataSender.foo = myTextBox.text;
//Call flash's send function to send foo to the php script
//Using "_self" will pass control to the php script
dataSender.send("testFlash.php", "_self", "POST");
}
/* Put the swf file in an html file and upload it to the server
Create the below php file and save it as testFlash.php:
<?php
echo "foo= $foo";
?>
Push testFlash.php to the same directory on the server and hit
your html file with your browser.
Parts of this code taken from:
http://www.thegoldenmean.com/technique/flashMX_mailform1.html
and
http://actionscript-toolbox.com/samplemx_php.php
*/