Tuesday, February 16, 2010

PHP and Flash Interaction Through XML and Actionscript

Flash can interact with dynamic data using XML files and also submit data to the php code using Action Script's getURL function. The getURL function in ActionScript can be used to set the external url to links and also for the flash form submissions. You can send any variable value from within the flash file to a PHP file. For example the following code,

getURL("fromFlash.php", "_blank", "POST");

can be used to send variables from Flash to a PHP file fromFlash.php. The variable sent according to the code above use the POST method. You can use the $_POST('variable_name') to get the data from the flash file and assign that value to some other variable within the PHP file. It is so easy to do it.

To load XML data in flash you can create an XML object and use that object's Load method to load the XML file you need.