0
votes

I have several swfs that use AS 1/2 to color state maps based on xml data. This worked great for a couple of years, but now the xml file has been updated. 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. 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

1

1 Answers

0
votes

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. Just change the file name or add a cache buster query to the end of the swf extension e.g. 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.

Lastly, I know this sound silly, but open the XML file in the browser and confirm it's the right one. For instance, view it directly e.g. 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 e.g. 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. 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. 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. See if it's referencing the new XML and has the cache buster query appended.

When I follow the above steps, it generally works for me. I hope it helps you, too.