I’ve created a Flash app that calls on a php file to grab data from mysql, and returns it back to Flash. It runs just great on it’s own.
The data-loading code looks like this, and works just fine:
In AS3:
// Grabs the data from the MySQL db via a PHP file
var myLoader:URLLoader = new URLLoader();
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
myLoader.load(new URLRequest("data.php"));
// Listens for when data is finished downloading, then runs app
myLoader.addEventListener(Event.COMPLETE, runApp);
function runApp() {
for(var p:uint=0; p<evt.target.data.dataCount; p++){
// Sets up an array in an array
product_array[p] = new Array();
// Adds product variables to array in array
product_array[p]["title"] = evt.target.data["Title"+p];
product_array[p]["image"] = evt.target.data["Image"+p];
}
}
The PHP file:
<?php
$connect222 = mysql_connect("localhost", "username", "password");
mysql_select_db("mydatabase", $connect222);
$result222 = mysql_query("SELECT Title, Image FROM myProducts ORDER BY Title");
$dataCount = 0;
while($row=mysql_fetch_array($result222)){
echo "Title$dataCount=$row[Title]&Image$dataCount=$row[Image]&";
$dataCount++;
}
echo "dataCount=$dataCount";
mysql_close($connect222);
?>
The SWF renders just fine on it’s own, all data comes through.
THE PROBLEM: Running that very same SWF inside of a custom Drupal PHP node does not work. I get IOERROR 2032 returning. I know the database connection does work just fine in Drupal because I take the above PHP code, apply it directly to the custom PHP node WITHOUT the SWF, and all the data spits out on the node page. For whatever reason, with an SWF which is inside of a Drupal node, the SWF cannot call on a PHP file for return data. I don’t have time to figure this out, so…
Because I can successfully spit the PHP return data out on the same node page as the SWF, how can I transfer that data to the SWF on the same page?
Seems like Javascript is the best solution?
Instead of using URLLoaderDataFormat.VARIABLES in AS3, how would I call on a plain old array from javascript on the same page as the SWF?