views:

336

answers:

2

Hi

Is it possible to load an image(jpg, png, gif) from another domain and manipulate the pixels? I guess when the image is downloaded/copied it is in my domain.

Using the Loader and add the content to an Image component I get an error in my debugger. I guess there are some cross domain polices at work here.

But I need to be more sure how this works before moving on. I guess, if it is not possible to load the image directly I could create a local proxy.

Could someone please enlighten me,

Thanks in advance,

Ran

+4  A: 

Hi Ran,

If the other domain that you're loading the images from allows you to ( has a crossdomain.xml with your domain listed there ) then all you need to do is setup your loader context so it loads checks for policy files by default.

Here's a snippet:

var loaderContext:LoaderContext = new LoaderContext(true);
var loader:Loader = new Loader();
loader.load(new URLRequest('http://someserver.com/yourImage.jpg'),loaderContext);

Otherwise, you might need to use some server side language to load the image and write it on you domain. After that is done, you should be able to do all the manipulation you need.

Goodluck, George

George Profenza
A: 

If the server doesn't have a crossdomain file, you can create a php file which uses CURL to grab any image and send it to your flash file. That way flash thinks it comes from the server. Not the most effeciant process but works.

Ross