简体   繁体   English

瑞士法郎不加载更新的XML数据

[英]swf not loading updated xml data

I have several swfs that use AS 1/2 to color state maps based on xml data. 我有几个使用AS 1/2来基于xml数据着色状态图的swf。 This worked great for a couple of years, but now the xml file has been updated. 这工作了好几年,但现在xml文件已更新。 The swfs will not load the new info. 瑞士法郎不会加载新信息。 It's like they did it once and it's now set in stone. 就像他们做过一次一样,现在它已经固定在石头上了。 I've searched for a week and tried several cache busters, but none have worked. 我已经搜索了一个星期,并尝试了几次缓存破坏程序,但是都没有成功。 Most of the things I've tried were based on adding a date/time stamp to the xml load statement. 我尝试过的大多数操作都是基于在xml加载语句中添加日期/时间戳。 These either had no effect or broke the application. 这些要么无效,要么中断了应用程序。 Here's the code: 这是代码:

var dp = new Array();
dp_xml = new XML();
dp_xml.ignoreWhite = true;
dp_xml.load('dplaws.xml');
dp_xml.onLoad = function(sucess) {
        if (sucess) {
                parseFile(dp_xml);
                showArray();
        }
};



function Map(state, category, qid, question, response) {
        this.state = state;
        this.category = category;
        this.qid = qid;
        this.question = question;
        this.response = response;

        if((substring(response,1,3)=="Yes") && (qid == "b")) {
            myColor = new Color(state);
            myColor.setRGB(0xA2B5CD);
        } else if((substring(response,1,3)!="Yes") && (qid == "b")) {
            myColor = new Color(state);
            myColor.setRGB(0xcccccc);
        }
}


function parseFile(xmlDoc_xml) {
        temp = new Array();
        for (var a = 0; a<xmlDoc_xml.firstChild.childNodes.length; a++) {
                for (var b = 0; b<xmlDoc_xml.firstChild.firstChild.childNodes.length; b++) {
                        temp[b] = xmlDoc_xml.firstChild.childNodes[a].childNodes[b].firstChild.nodeValue;
                }
                n = new Map(temp[0], temp[1], temp[2], temp[3], temp[4]);
                dp.push(n);
        }
}


function showArray(){
for (var z = 0; z<dp.length; z++) {
        trace(dp[z].state);
        trace(dp[z].category);
        trace(dp[z].question);
        trace(dp[z].response);
        trace(dp[z].qid);
}
}

Thanks for any help, Debbie 感谢您的帮助,黛比

You need to be aware of three things. 您需要注意三件事。

First you need to make sure you're loading the most up to date version of the SWF file to reference the new xml. 首先,您需要确保要加载最新版本的SWF文件以引用新的xml。 Just change the file name or add a cache buster query to the end of the swf extension eg map.swf?vers=2 . 只需更改文件名或在swf扩展名的末尾添加缓存无效化查询即可,例如map.swf?vers = 2

Secondly, you need to check that the flash file is actually retrieving the correct and new XML file that has been updated. 其次,您需要检查Flash文件是否确实在检索已更新的正确的新XML文件。

Lastly, I know this sound silly, but open the XML file in the browser and confirm it's the right one. 最后,我知道这听起来很愚蠢,但是在浏览器中打开XML文件并确认它是正确的文件。 For instance, view it directly eg www.mydomain.com/dplaws.xml . 例如,直接查看它,例如www.mydomain.com/dplaws.xml I had quite a few occurrences where the file on the server was not up to date or the server itself was caching the file. 在服务器上的文件不是最新的或者服务器本身正在缓存文件的情况下,出现了很多次。 At least with the latter, you can then isolate it to being a problem with the server. 至少可以使用后者,然后将其隔离为服务器问题。

Check the XML file directly eg www.mydomain.com/dplaws.xml and add a query to end such as here (which can be anything) www.mydomain.com/dplaws.xml?cache=test9393 . 直接检查XML文件,例如www.mydomain.com/dplaws.xml并添加一个查询到结尾(例如此处(可以是任何内容)) www.mydomain.com/dplaws.xml?cache=test9393 With the query appended it should get the most recent version from the server. 附加查询后,它应该从服务器获取最新版本。

Now, once the above is confirmed, use Chrome and open the Developer Tools . 现在,一旦确认上述内容,请使用Chrome并打开开发人员工具 Go to the Network Tab and check if your flash is using the most up to date version. 转到“ 网络”标签,然后检查您的闪光灯是否正在使用最新版本。 You can see that once the SWF has loaded one of the next queries should be the XML file. 您可以看到,一旦SWF加载完毕,下一个查询之一就是XML文件。 See if it's referencing the new XML and has the cache buster query appended. 查看是否引用了新的XML,并附加了缓存无效化查询。

When I follow the above steps, it generally works for me. 当我按照上述步骤操作时,通常对我有用。 I hope it helps you, too. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM