Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading external images from another domain

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.

like image 855
Ran Avatar asked Jan 22 '23 17:01

Ran


2 Answers

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

like image 66
George Profenza Avatar answered Feb 01 '23 04:02

George Profenza


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.

like image 37
Ross Avatar answered Feb 01 '23 03:02

Ross