问题
xml, and i want to get data from external file xml in remote server using AS3, My problem is data xml is showing in consol (trace (data)) but not showing in swf file. if the swf and xml are in the same domain there is no problem.
my crossdomain
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
<site-control permitted-cross-domain-policies="by-content-type"/>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
and my code as3.
`
import flash.text.TextField;
import flash.system.Security;
//var p:TextField = new TextField();
//Security.allowDomain("my.domain.com");
Security.loadPolicyFile("http://my.domain.com/crossdomain.xml");
var myXML:XML = new XML();
var myLoader:URLLoader = new URLLoader();
myLoader.addEventListener(Event.COMPLETE, processXML);
myLoader.load(new URLRequest("http://my.domain.com/dataxml.xml?nocache="+Math.random()*28));
function processXML(e:Event):void {
myXML = XML(e.target.data);
p.text=myXML.IMAGE[1].@TITLE;
//trace(p);
//addChild(p);
for (var i:int = 0; i<myXML.*.length(); i++){
trace("My image number is " + (i+1) + ", it's title is " + myXML.IMAGE[i].@TITLE + " and it's URL is " + myXML.IMAGE[i]);
trace("----------------"+myXML.IMAGE[i].@TITLE);
};
}`
回答1:
Yes, when you run your swf in Flash authoring (swf on your computer), it will be able to consume an XML from any domain.
XML gets blocked when the swf is on DomainA.com, and the xml is on DomainB.com UNLESS there's a cross domain policy that says it's ok for another domain to use the xml.
You have to substitute the proper urls in your code.
http://my.domain.com/dataxml.xml is an example url.
Note that my.domain.com is just an example, i set my owner domain in my file .fla.
来源:https://stackoverflow.com/questions/25066552/swf-not-updating-when-file-xml-and-swf-not-in-the-same-domain