August 29, 2007
Goodbye Image Proxy - Thank You flickr!

I'm very happy about Yahoo/flickr's great move to implement crossdomain.xml on their flickr image servers. This finally allows to use the BitmapData.draw() command with images downloaded from flickr.com without having to route it through a proxy on your own domain first. For me this means that I will save a lot of traffic on my various mashups and on top of that the download of the images should even be quicker.

One thing you have to watch out for if you are going to adapt your old AS2 code to these changes is that it is not enough to just download the images directly. You will have to instruct Flash first to download the new policy files from the flickr servers whenever it tries to access them. Since flickr distributes its images across several servers that have different domains like http://farm2.static.flickr.com, http://farm3.static.flickr.com and so on the easiest way to accomplish that is to use the MovieClipLoader class and to set its checkPolicyFile property to "true". This will instruct Flash to check for the crossdomain.xml file automatically on the respective server. Attention: In order to do that you will have to publish your files to Flash Player 9 since Flash 8 doesn't support that property.

Here's a simple AS2 example:

import flash.display.BitmapData;

var holder:MovieClip = createEmptyMovieClip("test",0);
var mcl:MovieClipLoader = new MovieClipLoader();
mcl.checkPolicyFile = true;
mcl.loadClip("http://farm2.static.flickr.com/1395/776413036_ea6bf98846_m_d.jpg",holder);
mcl.addListener( this );

var holder2:MovieClip = createEmptyMovieClip("test2",1);

function onLoadInit()
{
var bm:BitmapData = new BitmapData( holder._width,holder._height,false,0)
bm.draw(holder);
holder2.attachBitmap(bm,0);
holder2._x = holder._x + holder._width + 2;
}

The alternative way would be to use System.security.loadPolicyFile() but you will have to do that for every farm that you access - it is not enough just to load it from http://static.flickr.com/crossdomain.xml

For the AS3 way of dealing with this I recommend you Abdul Qabiz' old post about this topic.

Posted at August 29, 2007 09:10 PM | Further reading
Comments

mcl["checkPolicy"] = true should work? I just created flash app (SWF8) using mtasc and it works, ofcourse it needs Flash Player 9?

Am i missing anything?

-abdul

Posted by: Abdul Qabiz on October 25, 2007 01:41 PM
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?



Thank you!

Most Visited Entries
Sketches, Works & Source Code
Lectures
Contact
Backlog
In Love with
Powered by
Movable Type 2.661

© Copyright Mario Klingemann

Syndicate this site:
RSS 1.0 - RSS 2.0

Quasimondo @ flickr
Quasimondo @ LinkedIn
Quasimondo @ Twitter
Quasimondo @ Facebook
Quasimondo @ MySpace
Quasimondo is a Bright
Citizen of the TRansnational Republic
My other blog in german
Impressum


My family name is written Klingemann,
not Klingelmann, Klingeman, Klingaman, Kingemann,
Kindermann, Killingaman, Klingman, Klingmann, Klingonman
Klingemman, Cleangerman, Klingerman or Kleangerman

profile for Quasimondo at Stack Overflow, Q&A for professional and enthusiast programmers