XML data can’t be read by swf file when i publish it

I am trying to read data from a URL http://localhost:15979/default.aspx.The output of the url is :

<?xml version="1.0" encoding="utf-8"?>
<GALLERY>
<IMAGE TITLE="abs">image1.jpg</IMAGE>
<IMAGE TITLE="iron">image2.jpg</IMAGE>
<IMAGE TITLE="shop">image3.jpg</IMAGE>
</GALLERY>

I fetch this values into adobe flash cs with this code:

var myXML:XML = new XML(); 
var XML_URL:String = "http://localhost:15979/default.aspx"; 
var myXMLURL:URLRequest = new URLRequest(XML_URL); 
var myLoader:URLLoader = new URLLoader(myXMLURL); 
myLoader.addEventListener(Event.COMPLETE, xmlLoaded); 

function xmlLoaded(event:Event):void 
{ 
    myXML = XML(myLoader.data); 
    trace("Data loaded."); 
    txtname.text=myXML.IMAGE[1]<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c1ef819588958d84">[email protected]</a>;
}

So when i push ctrl +enter the swf file shows the result and every thing works fine ,but when i publish the swf file my XML file can’t be read and the myXML.IMAGE[1][email protected]; doesn’t apear on the screen.another problem is when i changed the xml ,the changes don’t apply in SWF file.

I changed the xml form to :

<?xml version="1.0"?>
<cross-domain-policy>
    <allow-access-from domain="*" secure="false" />
</cross-domain-policy>
<GALLERY>
<IMAGE TITLE="asas">image1.jpg</IMAGE>
<IMAGE TITLE="ssssss">image2.jpg</IMAGE>
<IMAGE TITLE="shop">image3.jpg</IMAGE>
</GALLERY>

But .fl file throws this error :

TypeError: Error #1088: The markup in the document following the root element must be well-formed.
    at _3333333333333333333333_fla::MainTimeline/xmlLoaded()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I finally add a cross domain file to my project as you can see here :

<?xml version="1.0" encoding="utf-8" ?> 
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="*"/>
<allow-access-from domain="*"/>
</cross-domain-policy>

and i call this file in my flash file like this :

Security.loadPolicyFile("http://localhost:15979/crossdomain.xml");

and every thing works fine .


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x