Okay, not sure if this the right place to put this, but I just wanted to share my discoveries, because I think others will find it incredibly useful. Taken originally from my blog at http://www.anthonycargile.com/blog/?p=36 :
Here’s what I needed this for: a client of mine is having me do a flash site, and as we all know flash is a one time deal, make the swf, embed it, and updates mean recompiling the swf. Now some get fancy and pass parameters to the movie via the corresponding HTML tag, but that could possibly lead to security vulnerabilities. Flash DOES, however, support reading external xml files over the network, allowing you to update an app just by re-uploading a new xml file, but for me, no, even that was not good enough.
This client of mine is a model. She gives me an average of 10 new pics a week to put on the (soon-to-be-old-yet-kept-for-accessibility-while-keeping-the-same-content-as-the-flash) site, which as mentioned above is a problem for flash. Enter using xml, which saves me from recompiling the whole shebang, but for an average 10 photos a week, I’m sorry but that is just waaay to much work for a programmer of my caliber.
So how do we do this same thing in flash? Well, flash was smarter than to to read an “xml” file with a .php extension, apparently hard-coded in there by adobe. So, since I favor Linux web hosting under apache, I made a little .htaccess file, and added:
in there. Now, I only did this because I am 100% sure that I won’t be needing anything else xml-related that would disagree with php for this website, otherwise I would put it in a directory, although I have not tested this.
AddType application/x-httpd-php .xml
What this does now, is let the webserver’s php processor execute any php code in any .xml file prior to serving it. I am lucky that flash is so client side that it actually REQUESTS the .xml file rather than open it (in a fopen() flashion) and then read the contents, which would just give the app php code, obviously not the desired effect here.
So now that php can process a .xml file before handing the output to flash upon request, I can just tell php to add a new xml tag for each image found in the album directories, which includes an image URL that flash can load into the app for viewing pleasure.