Action Script 3 loading images from remote domain

493 Views Asked by At

I have an application that is running on portal VK com. I need to load images (.png) from their domain (which are players avatars basicly). What I get is SecurityError: Error #2123. It looks like in crossdomain.xml file on their domain there is no proper tag.

I've done following things:

  1. Set allowSecurityDomain to * in my swf
  2. I'm passing LoaderContext to Loader::load method defined like this:

    var context:LoaderContext = new LoaderContext();
    var context.checkPolicyFile = true;
    loader.load(new URLRequest(img), context);
    

This is working on other portals (facebook, mojmir, odnoklassiniki, etc..) but not this one.

1

There are 1 best solutions below

1
On

If you want to load images you can use the Image tag:

 <mx:Image source="http://...." autoload="true" />

You won't have to deal with cross domain policy.

In AScript you can use:

var img:Image = new Image();
img.autoLoad = true;
img.source = "http://someurl/img.png"
img.addEventListener(Event.COMPLETE, function(e:Event):void {
   //loaded
});
img.addEventListener(IOErrorEvent.IO_ERROR, function(e:IOErrorEvent):void {
   //not loaded
});