【问题标题】:Flash AS3 not loading the xml when accessed onlineFlash AS3在线访问时不加载xml
【发布时间】:2010-11-08 06:19:27
【问题描述】:

直升机

我正在通过 Test Movie 在我的 flash 环境中获取 xml 数据。但是上传时它不显示数据。请注意,这里我没有加载扩展名为 .xml 的物理文件,而是加载了一个 url 引用,该引用创建了一个 xml 结构供此 flash 对象使用。

代码如下:

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 期间加载数据,但通过上面的链接访问时失败。

非常感谢任何帮助。

【问题讨论】:

    标签: flash actionscript-3


    【解决方案1】:

    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/

    【讨论】:

      【解决方案2】:

      我有同样的问题,我设法解决了。 问题只是我有一个名为“Gallery.xml”的xml文件。 但我正在用这样的非大写字母 G 加载它:

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

      这将始终离线工作(在您自己的电脑上) - 但不能在线。 所以我只是像这样更改代码:

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

      一切都非常棒。

      【讨论】:

        【解决方案3】:
        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 
        } 
        

        你的错是你的链接没有扩展!!

        【讨论】:

          猜你喜欢
          • 2010-11-15
          • 2014-01-29
          • 1970-01-01
          • 2017-01-16
          • 1970-01-01
          • 2011-06-03
          • 2016-06-13
          • 1970-01-01
          • 2012-01-05
          相关资源
          最近更新 更多