It’s been over two years since we (myself and Leif) created Arrivals.

At my last lecture, in which I talked about webservices, I took it out of the drawer to show my students. I was amazed that it still worked – offline that is. For some reason the images of the first destination (Paris) would not show. So today I set out to fix that. The problem only beeing present on the first destination, I thought it had something to do whit load time, but still found that rather puzzling as I new the code would handle that. I looked at the XML returned from Flickr and noticed that the farms that images from the first destination was located on, all had a rather hight id number, so I started to suspect the problem was related to the crossdomain policy issue. (This was made in as3) I was correctly loading a crossdomain.xml file from the Flickr site as such:
for (var j:uint = 1; j<5; j++) {
Security.loadPolicyFile('http://farm'+j+'.static.flickr.com/crossdomain.xml');
}
Notice that the code is handling the fact that there is a crossdomain.xml for each farm on flickr, then to be on the safe side loads all 5 of them. Problem is this number increases over time – as Flickr adds more farms to host people’s images. Why oh why did I decide to hardcode the limit value (5)? Could it be that when I wrote the code I didn’t completely grasp why I had to load these policy files in the first place? I guess so. Anyway, looking at it today it took me NO TIME to se that I did not need to load ‘all’ (read 5) policy files for each farm – for each image. I only need to load the policy file for the farm on which the current image is located. And which farm I need to load with a given image, is in the data returned from Flickr: photo.@farm. So the loop was replaced with this single line:
Security.loadPolicyFile('http://farm'+photo.@farm+'.static.flickr.com/crossdomain.xml');
And now the Arrivals app works again. Hurray!




















































