Pass xml data to a swf object
The Context of the Problem
I'm working on a rotator banner in flash. I use an external xml file to pass the banners info (like info-text, link, image-path, priority, etc). Everything is going well so far. I'm loading the xml something like this:
var bannersXML:XML = new XML();
bannersXML.ignoreWhite = true;
bannersXML.load("myBanners.xml");
The Problem itself
Now I need to construct this xml on-the-fly in php and somehow pass it to my flash object. So instead of read the external file I want my flash script receive an xml parameter it can work with.
Do you know if 开发者_StackOverflow社区this can be done?
Echo out the structure of the XML file with appropriate headers and tell Flash to load your PHP file:
<?
header("Content-type: text/xml");
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "whatever other xml tags";
$xml_output .= "whatever other xml tags";
$xml_output .= "whatever other xml tags";
$xml_output .= "whatever other xml tags";
echo $xml_output;
?>
This is a bit simplified, but that's the idea. Then just call:
bannersXML.load("myBannersPHPfile.php");
精彩评论