Copy link to clipboard
Copied
I am using the XML/MX/Syndication libraires and getting a Security Error #2048 error. The error seems unreasonable to me in that there is no forward solution to it on the Internet. I have tried hardcoding security methods in AS 3 and also using a crossdmain.xml file in my root directory to no success. I am about to give up and use pure PHP. There should be a more simple solution to this.
1 Correct answer
you php file needs to read the xml feed and then you can echo that back to flash.
Copy link to clipboard
Copied
if you're trying to load an xml file/feed from one domain into a swf on another domain, you're going to have a cross-domain security issue. to remedy, call a php file on the same domain as the swf, have the php script load the other-domain xml file and feed that xml file to your swf.
Copy link to clipboard
Copied
First I want to say thanks for the help. It was real hard searching for this answer.
I am writing something like this in my index.php page that calls the galaxy.php script which calls the swf file.
<?php
include( $_SERVER['DOCUMENT_ROOT'] . 'http://www.jpl.nasa.gov/multimedia/rss/news.xml');
include 'galaxy.php';?>
Now at least I get this error:
IOError : Error #2032
My A3 is:
const RSS_URL:String = "http://www.journeyon.us/news.xml";
Copy link to clipboard
Copied
you're welcome.
(but i don't see where you're as3 is calling your php file and it's not clear what your php file is doing.)
Copy link to clipboard
Copied
The URL is called in the timeline before the button load event that loads the RSS feed.
In my index.php file, first I am trying to include the xml file to my server root directory and then load in the swf file.
I am not sure if this is the correct way to do it though.
Copy link to clipboard
Copied
use the urlloader class to call your php script and a listener for the return from that script.
Copy link to clipboard
Copied
it wants to parse the RSS xml file and errors out if it's a php file.
How can I retrieve the xml file from the php file?
I'm doing something like this:
function onDataLoad(e:Event):void
{
// get the raw string data from the feed
var rawRSS:String = URLLoader(e.target).data;
//parse it as RSS
parseRSS(rawRSS);
}
but I am capturing a PHP file that loads the XML file not the pure XML file.
Maybe use this to retrive the exact variables:
request.data = new URLVariables();
Copy link to clipboard
Copied
I am getting an invalid XML data error while using URLRequestMethod.GET
with the php file:
In the file is
<?php include 'http://www.jpl.nasa.gov/multimedia/rss/news.xml'; ?>
It's proabably reading the php syntax and then erroring
Copy link to clipboard
Copied
you php file needs to read the xml feed and then you can echo that back to flash.
Copy link to clipboard
Copied
I am using htmlentities() here. It's working great and I print out exactly the source that the original xml file contains.
But it still can't read it. Maybe it's because it's a PHP file and not .XML?
<?php
$url = 'http://www.jpl.nasa.gov/multimedia/rss/news.xml';
$xml = simplexml_load_file($url) or die ("Unable to load XML file!");//echo '<pre>'.htmlentities(print_r($xml, 1)).'</pre>';
echo htmlentities("<?xml version='1.0'?>");
echo htmlentities("<rss version='2.0'>");
echo htmlentities("<channel>");
foreach ($xml->channel->item as $item)
{
echo htmlentities("<item>");
echo htmlentities("<title>");
echo $item->title;
echo htmlentities("</title>");
echo htmlentities("<link>");
echo $item->link;
echo htmlentities("</link>");
echo htmlentities("<description>");
echo $item->description;
echo htmlentities("</description>");
echo htmlentities("<pubDate>");
echo $item->pubDate;
echo htmlentities("</pubDate>");
echo htmlentities("</item>");
}echo htmlentities("</channel>");
echo htmlentities("</rss>");
?>
Copy link to clipboard
Copied
You shouldn't be using htmlentities in php to generate xml for loading in actionscript in this case.
htmlentities encodes the xml tags so they can be viewed in a browser as html.
When you're loading the xml with flash you want the raw xml without html entity encoding.
Copy link to clipboard
Copied
I just added this to the top and it produces a raw XML file.
header("Content-Type: text/xml");
removed this:
echo "<?xml version='1.0'?>";
works now.

