load XML file from addon domain without cross-domain Policy file
hello.
assuming there 2 addon domains on same server: /public_html/domain1.com and /public_html/domain2.com
i try load xml file domain2.com domain1.com without using cross-domain policy file (since doesn’t work on xml files in case).
so idea use php file in order load xml , read flash.
i’ve found interesting scripts seems job unfortunately can't work. in opinion there somewhere problem as3 part. please take look.
here as3/php scripts:
as3 (.swf in www.domain1.com):
// location of xml load, full http address
var xmlloc:string = "http://www.domain2.com/myfile.xml";
// location of php xml grabber file, in relation .swf
var phploc:string = "loadxml.php";
var xml:xml;
var loader:urlloader = new urlloader();
var request:urlrequest = new urlrequest(phploc+"?location="+escape(xmlloc) );
loader.addeventlistener(event.complete, onxmlloaded);
loader.addeventlistener(ioerrorevent.io_error, onioerrorhandler);
loader.load(request);
function onioerrorhandler(e:ioerrorevent):void {
trace("there error xml file "+e);
}
function onxmlloaded(e:event):void {
trace("the rss feed has been loaded");
xml = new xml(loader.data);
// set string, since passed php object
xml = xml(xml.tostring());
xml_txt.text = xml;
}
php (loadxml.php in www.domain1.com):
<?php
header("content-type: text/xml");
$location = "";
if(isset($_get["location"])) {
$location = $_get["location"];
$location = urldecode($location);
}
$xml_string = getdata($location);
// pass url encoded vars flash
echo $xml_string;
//curls url , returns it
function getdata($query) {
// create curl resource
$ch = curl_init();
// curl url
curl_setopt($ch, curlopt_url, $query);
//set necessary params using curl
curl_setopt($ch, curlopt_ssl_verifypeer, false);
curl_setopt($ch, curlopt_returntransfer, 1);
//execute curl function, , decode returned json data
$result = curl_exec($ch);
return $result;
// close curl resource free system resources
curl_close($ch);
}
?>
do either of 2 traces swf functions? if 1 onxmlloaded function, have traced loader.data? if 1 onioerrorhandler function, swf file in same folder html page embeds it?
More discussions in ActionScript 3
adobe
Comments
Post a Comment