2010-11-08 45 views
1

HeloFlash AS3在線訪問時不加載xml

我正在通過測試影片獲取我的Flash環境中的xml數據。但上傳時不顯示數據。請注意,在這裏我沒有加載帶.xml擴展名的物理文件,而是加載了一個url引用,它爲這個flash對象創建了一個xml結構。

的代碼如下:

var xmlLoader:URLLoader = new URLLoader(); 
xmlLoader.addEventListener(Event.COMPLETE, showXML); 
xmlLoader.load(new URLRequest("http://www.warraq.cc/Core/waraq/quiz-getcurrentexam")); 
function showXML(e:Event):void { 
XML.ignoreWhitespace = true; 
var songs:XML = new XML(e.target.data); 
trace(songs); 
b.text = songs; //b is the name given to the text box which is a TLF text box 
} 

///代碼結束

上傳的網址是: http://evuae.com/desben/quiz/tst2.html

它測試的SWF中加載數據,但是當通過訪問失敗上面的鏈接。

任何幫助非常感謝。

回答

2

看來http://evuae.com沒有crossdomain.xml策略文件。訪問你的鏈接返回安全錯誤

出於測試目的,創建一個文件名爲crossdomain.xml的複製本,然後將其加載到您的公共文件夾,以便它可以在http://evuae.com/crossdomain.xml

<?xml version="1.0"?> 
<!DOCTYPE cross-domain-policy SYSTEM 
    "http://www.adobe.com/xml/dtds/cross-domain- policy.dtd"> 
<cross-domain-policy> 
    <site-control permitted-cross-domain-policies="master-only"/> 
    <allow-access-from domain="*"/> 
</cross-domain-policy> 

訪問請注意這是最寬鬆的策略文件,因此您應該瞭解有關策略文件的更多信息並瞭解如何使其更具限制性。

http://tv.adobe.com/watch/how-to-develop-secure-flash-platform-apps/crossdomain-policy-files/

0
var xmlLoader:URLLoader = new URLLoader(); 
xmlLoader.addEventListener(Event.COMPLETE, showXML); 
xmlLoader.load(new URLRequest("http://www.warraq.cc/Core/waraq/quiz-getcurrentexam.xml")); 

function showXML(e:Event):void 
{ 
XML.ignoreWhitespace = true; 
var songs:XML = new XML(e.target.data); 
trace(songs); 
b.text = songs; 
//b is the name given to the text box which is a TLF text box 
} 

你的錯,是你的鏈接有沒有extention!

1

我有同樣的問題,我設法解決它。 問題很簡單,我有名爲「Gallery.xml」的xml文件。 但我是與非captlized政函加載這樣的:

myXMLLoader.load(new URLRequest("gallery.xml")); 

,這將始終脫機工作(在您自己的電腦) - 但不能上網。 所以我只是改變了這樣的代碼:

myXMLLoader.load(new URLRequest("Gallery.xml")); 

,一切工作非常真棒。