I don't quite understand -- I've never heard of an "undefined index" error. what exactly IS the index? A file? There are a lot of little things you need to know about when loading scripts in Flash, and I think we covered most of them, but there's one thing I don't believe I mentioned...
I think I remember reading somewhere that you can only use loadVariables with a script that lives in the same directory (a.k.a. folder) as the level0 flash SWF file (the main movie). I have had some luck accessing remote files, but only if I give the full path. For example "http://www.danludwig.com/file.php" would work OK but "/file.php" and "../file.php" are both bad...
One thing I'm curious about - how can you tell what error the PHP script is getting when loaded into the Flash movie? How can you see its output? Do you retrieve it through Flash somehow? There's a little experiment I tried once to see how PHP and Flash talked to each other. There isn't a ton of literature on it, so experimentation was necessary. This requires a MySQL or other kind of database though:
Make a table named "test" in your database with 2 text columns named "key" and "value."
Insert this code into a PHP file:
<?php
//THIS CAN ALSO BE WRITTEN EXPLICITLY
require("connect_to_database.php");
//THIS IS THE MONEY CODE
while(list($key ,$value) = each($HTTP_POST_VARS)) {
$query = "insert into test (key, value) values ('$key', '$value')";
mysql_query($query);
}
$query = "insert into test (key, value) values ('script', 'finished')";
mysql_query($query);
?>
- Make a new Flash movie and save it in the SAME FOLDER as the script. Add this code to frame 1:
this = "That";
theOtherThing = "What?";
_root.loadVariables("script.php", "POST");
stop();
- Publish the movie, then upload the resulting HTML and SWF files along with your script to the SAME folder on your web server. After you access the HTML file in a browser, this is what happens:
2 variables are declared in the _root of your SWF file.
Those variables are both sent via post to the script.
The script loops through each key/value pair, inserting a new row into the table for each pair. After accessing your script, this is what your table should look like:
[key] [value]
this that
theOtherThing What?
script finished
Try that out if you can. Good luck.
P.S. -- In case you're wondering, the ""connect_to_database.php" file would ALSO have to live in the same folder as the script, SWF, and HTML file. I can't say it enough ...put it ALL in the same folder!